VintaSoft Barcode .NET SDK 16.0: Documentation for Web developer
In This Topic
Generate barcode image in ASP.NET Core application
In This Topic
This tutorial shows how to create a blank ASP.NET Core Web application in Visual Studio .NET 2026 and generate barcode image in ASP.NET Core application.

Here are steps, which must be done:
  1. Create a blank ASP.NET Core Web application.

    Open Visual Studio .NET 2026 and create a new project, of "ASP.NET Core Web App (Model-View-Controller)" application type:

    Configure the project to use .NET 10.0:

  2. Server side: Add references to the Vintasoft nuget-packages to ASP.NET Core Web application.

    Add references to the nuget-packages Vintasoft.Barcode, Vintasoft.Barcode.SkiaSharp and Vintasoft.Barcode.AspNetCore.ApiControllers to the ASP.NET Core project.
    Comment: Reference to the nuget-package Vintasoft.Barcode.SkiaSharp is necessary only if SDK should draw text value of barcode on barcode image. Instead of nuget-package Vintasoft.Barcode.SkiaSharp can be used nuget-package Vintasoft.Barcode.ImageSharp or Vintasoft.Barcode.Gdi.

  3. Server side: Add Web API controller that allows to generate barcode image.

    • Press the right mouse button on the "Controllers" folder and select the "Add => Controller..." menu from context menu
    • Select Empty API controller template, set the controller name to the "MyVintasoftBarcodeApiController" and press the "Add" button
    • Specify that MyVintasoftBarcodeApiController class is derived from Vintasoft.Barcode.AspNetCore.ApiControllers.VintasoftBarcodeApiController class

      Here are source codes of MyVintasoftBarcodeApiController class:
      using Vintasoft.Barcode.AspNetCore.ApiControllers;
      
      namespace WebApplication1.Controllers
      {
          public class MyVintasoftBarcodeApiController : VintasoftBarcodeApiController
          {
      
              public MyVintasoftBarcodeApiController(IWebHostEnvironment hostingEnvironment)
                  : base(hostingEnvironment)
              {
              }
      
          }
      }
      
      

  4. Server side: Specify that VintaSoft Barcode .NET SDK should use SkiaSharp library for drawing of 2D graphics.

    Open file "Program.cs" and add code line "Vintasoft.Barcode.SkiaSharpAssembly.Init();" at the beginning of file:

    Here are source codes of Program.cs file:
    // specify that VintaSoft Barcode .NET SDK should use SkiaSharp library for drawing of 2D graphics
    Vintasoft.Barcode.SkiaSharpAssembly.Init();
    
    var builder = WebApplication.CreateBuilder(args);
    
    // Add services to the container.
    
    builder.Services.AddControllersWithViews().AddNewtonsoftJson();
    
    var app = builder.Build();
    
    app.UseDefaultFiles();
    app.MapStaticAssets();
    
    // Configure the HTTP request pipeline.
    
    app.UseHttpsRedirection();
    
    app.UseAuthorization();
    
    app.MapControllers();
    
    app.MapFallbackToFile("/index.html");
    
    app.Run();
    
    
  5. Client side: Add Vintasoft JavaScript files to the project.

  6. Client side: Add JavaScript code, which generate barcode and displays generated barcode image, to the web view.

    • Open file "Views\Home\Index.cshtml", clear the file, add HTML code (references to VintaSoft JavaScript files; IMG-element that will display generated barcode image) to the "Index.cshtml" file:

      Here is HTML code of "Index.cshtml" file:
      <script src="~/lib/Vintasoft/Vintasoft.Shared.js" type="text/javascript"></script>
      <script src="~/lib/Vintasoft/Vintasoft.Barcode.js" type="text/javascript"></script>
      
      <img id="barcodeImage" src="" />
      
      

    • Open file "wwwroot\js\site.js", clear the file, add JavaScript code (generates barcode image and displays generated barcode image) to the "site.js" file:

      Here is JavaScript code that generates barcode image and displays generated barcode image:
      /**
       * Generates 1D barcode image.
       */
      function generate1dBarcodeImage(barcodeType, barcodeValue) {
          // create service that allows to generate barcode
          var barcodeService = new Vintasoft.Shared.WebServiceControllerJS("/vintasoft/api/MyVintasoftBarcodeApi");
      
          // create the barcode writer
          var barcodeWriter = new Vintasoft.Barcode.WebBarcodeWriterJS(barcodeService);
      
          // create the barcode writer settings for generating 1D barcode
          var barcodeWriterSettings = new Vintasoft.Barcode.Web1DBarcodeWriterSettingsJS();
          // specify that barcode writer must generate QR barcode image
          barcodeWriterSettings.set_BarcodeType(new Vintasoft.Barcode.Web1DBarcodeTypeEnumJS(barcodeType));
          // specify the Code128 barcode value
          barcodeWriterSettings.set_Value(barcodeValue);
      
          // specify settings for barcode writer
          barcodeWriter.set_Settings(barcodeWriterSettings);
      
          // send an asynchronous request for getting barcode image as Base64 string
          barcodeWriter.getBarcodeAsBase64Image(__writeBarcode_success, __writeBarcode_failed);
      }
      
      /**
       * Generates 2D barcode image.
       */
      function generate2dBarcodeImage(barcodeType, barcodeValue) {
          // create web service that allows to generate barcode
          var barcodeService = new Vintasoft.Shared.WebServiceControllerJS("/vintasoft/api/MyVintasoftBarcodeApi");
      
          // create the barcode writer
          var barcodeWriter = new Vintasoft.Barcode.WebBarcodeWriterJS(barcodeService);
      
          // create the barcode writer settings for generating 2D barcode
          var barcodeWriterSettings = new Vintasoft.Barcode.Web2DBarcodeWriterSettingsJS();
          // specify that barcode writer must generate QR barcode image
          barcodeWriterSettings.set_BarcodeType(new Vintasoft.Barcode.Web2DBarcodeTypeEnumJS(barcodeType));
          // specify the QR barcode value
          barcodeWriterSettings.set_Value(barcodeValue);
      
          // specify settings for barcode writer
          barcodeWriter.set_Settings(barcodeWriterSettings);
      
          // send an asynchronous request for getting barcode image as Base64 string
          barcodeWriter.getBarcodeAsBase64Image(__writeBarcode_success, __writeBarcode_failed);
      }
      
      /**
       * Barcode is generated successfully.
       */
      function __writeBarcode_success(data) {
          if (data.success) {
              var barcodeImage = data.barcodeImage;
              document.getElementById("barcodeImage").src = barcodeImage;
          }
          else {
              alert(data.errorMessage);
          }
      }
      
      /**
       * Barcode generation is failed.
       */
      function __writeBarcode_failed(data) {
          // show information about error
          alert(data.errorMessage);
      }
      
      
      // set the session identifier
      Vintasoft.Shared.WebImagingEnviromentJS.set_SessionId("SessionID");
      // generate image of QR barcode with value "12345"
      generate2dBarcodeImage("QR", "12345");
      
      

  7. Run the ASP.NET Core application and see the result.