VintaSoft Imaging .NET SDK 15.2: Документация для Веб разработчика
В этом разделе
Добавление веб DICOM-просмотрщика в приложение "ASP.NET Core Web App (Model-View-Controller)".
В этом разделе
В этом руководстве показано, как создать пустое приложение "ASP.NET Core Web App (Model-View-Controller)" в Visual Studio .NET 2026 и добавить DICOM просмотрщик в приложение ASP.NET Core.

Вот шаги, которые необходимо выполнить:
  1. Создайте пустое приложение "ASP.NET Core Web App (Model-View-Controller)".

    Откройте Visual Studio .NET 2026 и создайте новый проект типа приложения "ASP.NET Core Web App (Model-View-Controller)":

    Настройте проект для использования .NET 10.0:

  2. Серверная сторона: Добавьте ссылки на nuget-пакеты Vintasoft в приложение ASP.NET Core.

    Добавьте ссылки на nuget-пакеты "Vintasoft.Imaging.Dicom.AspNetCore.ApiControllers" и "Vintasoft.Imaging.Jpeg2000Codec" в приложение ASP.NET Core. Другие необходимые nuget-пакеты будут добавлены автоматически.



  3. Серверная сторона: Укажите движок рисования, который должен использоваться VintaSoft Imaging .NET SDK для рисования 2D-графики.

    Если ASP.NET Core приложение планируется использовать в среде Windows или Linux, рекомендуется применять графический движок SkiaSharp.
    Если ASP.NET Core приложение будет использоваться только в среде Windows, можно применять как графический движок System.Drawing, так и SkiaSharp.

    Вот шаги, которые необходимо выполнить для использования движка SkiaSharp:
    • Добавьте ссылку на nuget-пакет "Vintasoft.Imaging.Drawing.SkiaSharp". Ссылка на nuget-пакет "SkiaSharp" версии 4.151.1 будет добавлена автоматически.
    • Откройте файл "Program.cs", добавьте в начало файла строку кода "Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();" - добавленный код указывает, что VintaSoft Imaging .NET SDK должен использовать библиотеку SkiaSharp для отрисовки 2D-графики.

    Вот шаги, которые необходимо выполнить для использования движка System.Drawing:
    • Добавьте ссылку на nuget-пакет "Vintasoft.Imaging.Gdi".
    • Откройте файл "Program.cs", добавьте в начало файла строку кода "Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();" - добавленный код указывает, что VintaSoft Imaging .NET SDK должен использовать библиотеку System.Drawing для отрисовки 2D-графики.

  4. Серверная сторона: Создайте веб сервисы, которые позволяют загружать/скачивать файлы и просматривать DICOM-изображения.

    • Создайте веб сервис, позволяющий загружать/скачивать файл

      • Нажмите правую кнопку мыши на папке "Controllers" и выберите меню "Add => Controller..." из контекстного меню
      • Выберите шаблон "Empty API controller", установите имя контроллера "MyVintasoftFileApiController" и нажмите кнопку "Add".
      • Укажите, что класс MyVintasoftFileApiController является производным от класса Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController

        Вот исходные коды класса MyVintasoftFileApiController:
        using Microsoft.AspNetCore.Hosting;
        
        namespace WebApplication1.Controllers
        {
            public class MyVintasoftFileApiController : Vintasoft.Imaging.AspNetCore.ApiControllers.VintasoftFileApiController
            {
        
                public MyVintasoftFileApiController(IWebHostEnvironment hostingEnvironment)
                    : base(hostingEnvironment)
                {
                }
        
            }
        }
        
    • Создайте веб сервис, позволяющий работать с DICOM-изображениями

      • Нажмите правую кнопку мыши на папке "Controllers" и выберите меню "Add => Controller..." из контекстного меню
      • Выберите шаблон "Empty API controller", установите имя контроллера "MyVintasoftDicomApiController" и нажмите кнопку "Add".
      • Укажите, что класс MyVintasoftDicomApiController является производным от класса Vintasoft.Imaging.Dicom.AspNetCore.ApiControllers.VintasoftDicomApiController

        Вот исходные коды класса MyVintasoftDicomApiController:
        using Microsoft.AspNetCore.Hosting;
        using Vintasoft.Imaging.Dicom.AspNetCore.ApiControllers;
        
        namespace WebApplication1.Controllers
        {
            /// <summary>
            /// A Web API controller that handles HTTP requests from clients and
            /// allows to work with DICOM images.
            /// </summary>
            public class MyVintasoftDicomApiController : VintasoftDicomApiController
            {
        
                /// <summary>
                /// Initializes a new instance of the <see cref="MyVintasoftDicomApiController"/> class.
                /// </summary>
                public MyVintasoftDicomApiController(IWebHostEnvironment hostingEnvironment)
                    : base(hostingEnvironment)
                {
                }
        
            }
        }
        
  5. Клиентская сторона: Добавьте JavaScript-библиотеки в проект.

    • Добавьте папку "wwwroot\lib\Vintasoft" в приложение ASP.NET Core.

    • Скопируйте файлы Vintasoft.Shared.js, Vintasoft.Imaging.js, Vintasoft.Imaging.css, Vintasoft.Imaging.Dicom.js, Vintasoft.Imaging.Dicom.css из папки "<InstallPath>\VintaSoft Imaging .NET 15.2\Bin\JavaScript\" в папку "wwwroot\lib\Vintasoft".
    • Укажите, какие "стандартные" диалоги (показывать метаданные DICOM и т. д.) должны использоваться веб DICOM-просмотрщиком
      • Если веб DICOM-просмотрщик должен использовать готовые к использованию "стандартные" UI-диалоги Bootstrap:
        • Добавьте библиотеки Bootstrap и jQuery в проект.
        • Скопируйте файлы Vintasoft.Imaging.Dialogs.Bootstrap.js и Vintasoft.Imaging.Dicom.Dialogs.Bootstrap.js из папки "<InstallPath>\VintaSoft Imaging .NET 15.2\Bin\JavaScript\" в папку "wwwroot\lib\Vintasoft\".
      • Если веб DICOM-просмотрщик должен использовать готовые к использованию "стандартные" UI-диалоги jQuery UI:
        • добавьте библиотеки jQuery и jQuery UI в проект;
        • Скопируйте файлы Vintasoft.Imaging.Dialogs.jQueryUI.js и Vintasoft.Imaging.Dicom.Dialogs.jQueryUI.js из папки "<InstallPath>\VintaSoft Imaging .NET 15.2\Bin\JavaScript\" в папку "wwwroot\lib\Vintasoft\".
      • Если веб DICOM-просмотрщик должен использовать пользовательские "стандартные" диалоги, прочтите, как создать пользовательские "стандартные" диалоги здесь .

  6. Клиентская сторона: Добавьте JavaScript-код, позволяющий отображать DICOM-изображения.

    • Создайте папку "wwwroot\UploadedImageFiles\SessionID" и скопируйте в нее тестовый файл DICOM "<SdkInstallPath>\VintaSoft\Imaging .NET 15.2\Examples\ASP.NET Core\CSharp\AspNetCoreImagingDemo\wwwroot\UploadedImageFiles\LossyJpeg_Monochrome2_000.0000.dcm". Этот файл будет отображаться в DICOM-просмотрщике.

    • Откройте файл "Views\Home\Index.cshtml".



      Добавьте ссылки на используемые JavaScript-библиотеки:
      • Если вы используете диалоговые окна Bootstrap, добавьте ссылки на файлы Bootstrap и Vintasoft JavaScript-файлы.
        Вот HTML-код, который добавляет ссылки на файлы Bootstrap и Vintasoft JavaScript-файлы:
        <link rel="stylesheet" type="text/css" href="~/lib/bootstrap/dist/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.Dicom.css">
        
        <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js" type="text/javascript"></script>
        
        <script src="~/lib/Vintasoft/Vintasoft.Shared.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dialogs.Bootstrap.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dicom.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dicom.Dialogs.Bootstrap.js" type="text/javascript"></script>
        
        

      • Если вы используете диалоговые окна jQuery UI, добавьте ссылки на jQuery-файлы и Vintasoft JavaScript-файлы.
        Вот HTML-код, который добавляет ссылки на jQuery-файлы и Vintasoft JavaScript-файлы:
        <link rel="stylesheet" type="text/css" href="~/js/jquery-ui-css/jquery-ui.min.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.css">
        <link rel="stylesheet" type="text/css" href="~/lib/Vintasoft/Vintasoft.Imaging.Dicom.css">
        
        <script src="~/js/jquery-3.3.1.min.js" type="text/javascript"></script>
        <script src="~/js/jquery-ui.min.js" type="text/javascript"></script>
        
        <script src="~/lib/Vintasoft/Vintasoft.Shared.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dialogs.jQueryUI.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dicom.js" type="text/javascript"></script>
        <script src="~/lib/Vintasoft/Vintasoft.Imaging.Dicom.Dialogs.jQueryUI.js" type="text/javascript"></script>
        
        


      Добавьте HTML-разметку (div-элемент, который будет отображать DICOM-просмотрщик) в веб-представление:

      Вот код HTML-разметки:
      <div class="text-center">
          <h1>VintaSoft DICOM Viewer Demo (ASP.NET Core)</h1>
      
          <div id="dicomControlContainer" class="dicomControlContainer"></div>
      </div>
      
      

    • Откройте файл "wwwroot\css\site.css", добавьте CSS-стиль для "dicomControlContainer" в файл "site.css":
      html {
        font-size: 14px;
      }
      
      @media (min-width: 768px) {
        html {
          font-size: 16px;
        }
      }
      
      .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
        box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
      }
      
      html {
        position: relative;
        min-height: 100%;
      }
      
      body {
        margin-bottom: 60px;
      }
      
      .form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
        color: var(--bs-secondary-color);
        text-align: end;
      }
      
      .form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
        text-align: start;
      }
      
      .dicomControlContainer {
          height: 800px;
      }
      
      


    • Откройте файл "wwwroot\js\site.js", добавьте JavaScript-код, который инициализирует и создает DICOM просмотрщик:

      Вот JavaScript-код, который инициализирует и отображает DICOM-просмотрщик:
      // set the session identifier
      Vintasoft.Shared.WebImagingEnviromentJS.set_SessionId("SessionID");
      
      // specify web services, which should be used by Vintasoft Web DICOM Viewer
      Vintasoft.Shared.WebServiceJS.defaultFileService =
          new Vintasoft.Shared.WebServiceControllerJS("vintasoft/api/MyVintasoftFileApi");
      Vintasoft.Shared.WebServiceJS.defaultDicomService =
          new Vintasoft.Shared.WebServiceControllerJS("vintasoft/api/MyVintasoftDicomApi");
      
      // create DICOM control settings
      var dicomControlSettings = new Vintasoft.Imaging.Dicom.WebDicomControlSettingsJS("dicomControlContainer", "dicomControl");
      // create DICOM control
      var dicomControl = new Vintasoft.Imaging.Dicom.WebDicomControlJS(dicomControlSettings);
      
      // subscribe to the "warningOccured" event of DICOM control
      Vintasoft.Shared.subscribeToEvent(dicomControl, "warningOccured", function (event, eventArgs) { alert(eventArgs.message); });
      
      // add DICOM file "LossyJpeg_Monochrome2_000.0000.dcm" to the DICOM control
      dicomControl.addFiles(["LossyJpeg_Monochrome2_000.0000.dcm"]);
      
      
  7. Запустите приложение ASP.NET Core и посмотрите результат.