How to create barcodes through URL in C#
ASP.NET web app?

How to generate barcode image through URL in web browser using C# in ASP.NET (Core, Framework) web application?

Using C# class code to encode, print and customize barcode images for .NET applicaitons





In this C# tutorial, you will learn how to generate linear and 2d barcodes in multiple image formats, including raster images and vector images in your ASP.NET web app and Windows application.

  • Barcode image with color settings
  • Barcode image with transparent background
  • High resolution barcode image for printing
  • Multiple raster image formats and vector image formats supported

How to create high quality barcode images using C#

  1. Download .NET Barcode Generator Suite
  2. Install C# library to create barcode images in .NET apps
  3. Step by Step Tutorial












Setup barcode online generation streaming web service in ASP.NET

Top
Here we will show how to set up a barcode generation streaming service in ASP.NET web server for ASP.NET Core and ASP.NET Framework.

After setup completes, you could generate barcodes using URL in web browser or other applications.



Setup on IIS with ASP.NET Core

The following guide will create an ASP.NET Core Empty for Windows, which allows you to create QR Code and barcodes through URL.

Here are the requirements:
  • Visual Studio 2022
  • .NET 6.0 SDK
  • OnBarcode.Barcode.ASPNETCore.dll for Windows, or OnBarcode.Barcode.ASPNETCore.Skia.dll for Linux, MacOS, non-Windows


  • Step 1: Create a new project with project template "ASP.NET Core Empty".

  • Step 2: Choose framework .NET 6.0 (Long Term Support).

  • Step 3: Add project reference: assembly "OnBarcode.Barcode.ASPNETCore.dll" or "OnBarcode.Barcode.ASPNETCore.Skia.dll" to the project.

  • Step 4: For Windows: Install package "System.Drawing.Common" (Version 4.5.0 or later) by NuGet.
    For Linux, MacOS, non-Windows: Install package "SkiaSharp" (Version 2.80.0 or later) by NuGet.

  • Step 5: Replace content in file "Program.cs" by below C# codes
    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddHttpContextAccessor();
    var app = builder.Build();
    // Linear
    app.MapGet("/", async (IHttpContextAccessor httpContextAccessor) =>
    {
        var context = httpContextAccessor.HttpContext;
        if (context != null)
            await OnBarcode.Barcode.ASPNETCore.LinearWebStream.drawBarcodeAsync(context.Request, context.Response);
    });
    // PDF417
    app.MapGet("/PDF417", async (IHttpContextAccessor httpContextAccessor) =>
    {
        var context = httpContextAccessor.HttpContext;
        if (context != null)
            await OnBarcode.Barcode.ASPNETCore.PDF417WebStream.drawBarcodeAsync(context.Request, context.Response);
    });
    // DataMatrix
    app.MapGet("/DataMatrix", async (IHttpContextAccessor httpContextAccessor) =>
    {
        var context = httpContextAccessor.HttpContext;
        if (context != null)
            await OnBarcode.Barcode.ASPNETCore.DataMatrixWebStream.drawBarcodeAsync(context.Request, context.Response);
    });
    // QRCode
    app.MapGet("/QRCode", async (IHttpContextAccessor httpContextAccessor) =>
    {
        var context = httpContextAccessor.HttpContext;
        if (context != null)
            await OnBarcode.Barcode.ASPNETCore.QRCodeWebStream.drawBarcodeAsync(context.Request, context.Response);
    });
    // MicroPDF417
    app.MapGet("/MicroPDF417", async (IHttpContextAccessor httpContextAccessor) =>
    {
        var context = httpContextAccessor.HttpContext;
        if (context != null)
            await OnBarcode.Barcode.ASPNETCore.MicroPDF417WebStream.drawBarcodeAsync(context.Request, context.Response);
    });
    // MicroQRCode
    app.MapGet("/MicroQRCode", async (IHttpContextAccessor httpContextAccessor) =>
    {
        var context = httpContextAccessor.HttpContext;
        if (context != null)
            await OnBarcode.Barcode.ASPNETCore.MicroQRCodeWebStream.drawBarcodeAsync(context.Request, context.Response);
    });
    app.Run();
    

  • Step 6: Run the demo project (Press Ctrl+F5).

  • Step 7: You can send barcode settings through URL as below.
    Eg. Default is Linear barcode
    https://localhost:7158/?DATA=12345678&X=3
    https://localhost:7158/QRCode?DATA=12345678&X=10
    https://localhost:7158/MicroPDF417?DATA=123&X=2



Setup on IIS with .NET Framework

  • Copy barcode folder and its contents from the downloaded package to your IIS.
  • If the ASP.NET is using .NET Framework 4.x, copy dll file OnBarcode.Barcode.ASPNET.dll from {downloaded package}/dll/Net40/ to folder barcode/Bin
  • If the ASP.NET is using .NET Framework 2.x or 3.x, copy dll file OnBarcode.Barcode.ASPNET.dll from {downloaded package}/dll/Net20/ to folder barcode/Bin
  • Create a new virtual directory in IIS manager and name it barcode.
  • Restart IIS
  • Open web browser, navigate to: http://YourDomain:Port/barcode/qrcode.aspx?DATA=9876543210, you will view a QR Code generated in browser.




Integrate barcode web streaming in your applications

Top
Integrating the OnBarcode barcode streaming service into your applications is really a simple task.

What you need do is to pass our dynamic barcode image generation URL to your web pages IMG tag, or to your reporting and business appliations that are supporting loading and rendering image through URL.

Using ASP.NET Core web service
  1. Dynamic barcode image URL for 1D / Linear barcodes: http://localhost:[port]/?DATA=12345678&X=3
  2. Dynamic barcode image URL for Data Matrix barcodes: http://localhost:[port]/DataMatrix?Data=123ABC
  3. Dynamic barcode image URL for PDF-417 barcodes: http://localhost:[port]/PDF417?Data=123ABC
  4. Dynamic barcode image URL for Micro PDF-417 barcodes: http://localhost:[port]/MicroPDF417?Data=123ABC
  5. Dynamic barcode image URL for QR Code barcodes: http://localhost:[port]/QRCode?Data=123ABC
  6. Dynamic barcode image URL for Micro QR Code barcodes: http://localhost:[port]/MicroQRCode?Data=123ABC

ASP.NET Framework web service
  1. Dynamic barcode image URL for 1D / Linear barcodes: http://localhost:[port]/barcode/linear.aspx?DATA=12345678&X=3
  2. Dynamic barcode image URL for Data Matrix barcodes: http://localhost:[port]/barcode/datamatrix.aspx?Data=123ABC
  3. Dynamic barcode image URL for PDF-417 barcodes: http://localhost:[port]/barcode/pdf417.aspx?Data=123ABC
  4. Dynamic barcode image URL for Micro PDF-417 barcodes: http://localhost:[port]/barcode/micro-pdf417.aspx?Data=123ABC
  5. Dynamic barcode image URL for QR Code barcodes: http://localhost:[port]/barcode/qrcode.aspx?Data=123ABC
  6. Dynamic barcode image URL for Micro QR Code barcodes: http://localhost:[port]/barcode/micro-qrcode.aspx?Data=123ABC

You can add parameters to the end of url to set linear barcode type, data to encode, customize barcode image settings. More detail, view barcode parameters setting for each barcode type

C#.NET Barcode all supported barcode formats

Top

.NET Barcode Control DLL for C# - Barcodes Generation













OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.