ASP.NET QR Code Generator Library SDK

Integration & Developer Guide to generate QR Code barcode images in ASP.NET web applications

Generate barcode QR Code images in Visual ASP.NET web application with complete sample .NET source code

  • Generate, create QR Code in Visual ASP.NET applications
  • Easy to install & integrate 2D barcode QR Code generation library SDK into ASP.NET developments
  • Easy to encode GS1 data message to create standard GS1 QR Code barcodes
  • Generate industry standard linear, 2d barcode types including ASP.NET Data Matrix, ASP.NET PDF417, ASP.NET Code 39, ASP.NET Code 128
  • Generate QR Code images in ASP.NET class using C# or VB.NET
  • Generate and make QR Code 2d bar code images in ASP.NET web site
  • Create barcode QR Code images in ASP.NET web form application
  • Draw & print QR Code in SQL Server Reporting Services (SSRS) & Crystal Reports for ASP.NET projects
  • Easy to encode QR Code images to jpeg, gif, png, tiff, bitmap files in ASP.NET program
This page will help you learn how to generate QR Code (Quick Response Code) in ASP.NET projects using C# and a C# Barcode Generator library. It covers the entire process of QR Code generation, from basic implementation to advanced customization, and provides step-by-step instructions, code samples.



Below is a brief overview of the main content:
  • QR Code data encoding rules, including supported character sets, data modes, and maximum data length.
  • Methods to generate QR Code with different text formats (ASCII non-printable characters, Unicode text, GS1 data, Kanji text, binary data) in ASP.NET.
  • Customization options for QR Code images, such as dimension size, quiet zone, colors, and image resolution.
  • Advanced QR Code settings in ASP.NET projects, including error correction mode, version, Structured Append mode, FNC1 mode, and ECI mode.

ASP.NET QR Code Generator Control Introduction

Top
ASP.NET QR Code Generator is one of the barcode generation functions in OnBarcode's Barcode for ASP.NET Generation Controls, which generates & prints QR Code and 20+ other linear & 2D bar codes in ASP.NET web applications.
This article is providing several methods to use ASP.NET Barcode Generation Control to generate QR Code barcodes in ASP.NET web pages, ASP.NET web forms, and ASP.NET classes.

QR Code Generators

OnBarcode provides several QR Code Generator components and software, such as QR Code .NET, QR Code Java, QR Code C#, QR Code VB.NET, QR Code iPhone, QR Code iPad, QR Code Android, QR Code Generator.


Streaming QR Code Image into Your ASP.NET Web Pages

Top
  • Under downloaded trial package, copy barcode folder and its contents to your IIS, and create a new virtual directory, named "barcode".
  • Restart IIS, navigate to http://YourDomain:Port/barcode/qrcode.aspx?DATA=0123456789.
  • To create barcode image in html or aspx pages, you can insert a image tag (img) into your web pages.
    For example, <img src="http://YourDomain:Port/barcode/qrcode.aspx?DATA=0123456789" />

Generate QR Code into Your ASP.NET Web Forms

Top
  1. Install ASP.NET Barcode Generator Control.
  2. Add ASP.NET Barcode Generator Control to your Visual Studio ToolBox.
  3. Copy "qrcode.aspx" and "qrcode.aspx.cs" to the folder where your aspx pages are generating barcodes.
  4. Drag and drop "QRCodeWebForm" to your ASPX web forms.
  5. Run the website to view the barcodes generated. To customize QR Code settings, view QR Code barcode settings.

Generate QR Code Barcodes in ASP.NET Class

Top
If you need generate QR Code barcodes in your ASP.NET class using C# or VB.NET, we provides complete barcode generation source code for QR Code in C# and QR Code in VB.NET.


Key Concepts of QR Code Encoding in ASP.NET

To generate QR Codes effectively in ASP.NET projects, it is important to understand the key encoding concepts, including supported character sets, data modes, and maximum data length. These concepts ensure that the QR Code is encoded correctly and meets your web project requirements.


QR Code Encodable Character Set

QR Code supports multiple data formats, which can be used in ASP.NET projects to encode different types of information. The supported character sets are:
  • Numbers (digits 0-9): Suitable for encoding numeric data such as IDs or phone numbers.
  • ASCII characters (plain text): Includes standard printable characters (A-Z, a-z, 0-9, and special characters).
  • Unicode text: Supports international characters (e.g., Arabic, Greek, Thai) when encoded properly.
  • Byte data: Defaults to the ISO/IEC 8859-1 character set, but can be configured to use other character sets.
  • Kanji characters: Japanese characters that can be compacted into 13 bits for efficient encoding.



QR Code Data Mode

QR Code uses different data modes to encode data efficiently. The C# Barcode Generator library provides five data mode options, which can be set in your ASP.NET project code. The data mode is automatically selected by default, but you can specify it manually for specific use cases.

The five data modes (QRCodeDataMode) are:
  • QRCodeDataMode.Auto: The Barcode library automatically selects the most efficient data mode based on the input data (recommended for most ASP.NET use cases).
  • QRCodeDataMode.Numeric: For encoding numeric data only (digits 0-9), which is more efficient than other modes for numeric content.
  • QRCodeDataMode.AlphaNumeric: For alphanumeric data, including digits 0-9, uppercase letters A-Z, and nine special characters (space, $ % * + - . / :).
  • QRCodeDataMode.Byte: For byte data, which is used for encoding Unicode text, binary data, or non-ASCII characters.
  • QRCodeDataMode.Kanji: For encoding Kanji characters (Japanese), which are compacted into 13 bits to save space.
Note: Always set the data mode before setting the Data property to ensure the data is encoded correctly. If you are unsure about the data type, use QRCodeDataMode.Auto.


Maximum Data Length in QR Code

The maximum number of characters that can be encoded in a QR Code depends on the data mode and QR Code version (Version 40-L is the largest). In ASP.NET projects, this is important when encoding large amounts of data (e.g., in a Web API response).
  • Numeric data: 7,089 characters (Version 40-L).
  • Alphanumeric data: 4,296 characters (Version 40-L).
  • Byte data: 2,953 characters (Version 40-L).
  • Kanji data: 1,817 characters (Version 40-L).
Note: If your ASP.NET project requires encoding more data than the maximum length, consider using QR Code Structured Append mode to split the data into multiple QR Codes.


Generate QR Code with Various Text Formats in ASP.NET

ASP.NET projects often need to encode different text formats into QR Codes, such as non-printable ASCII characters, Unicode text, GS1 data, and Kanji text. The following sections provide step-by-step instructions for each text string format with sample code.


Generate QR Code with ASCII Non-Printable Characters

ASCII non-printable characters (e.g., Carriage Return [CR], Line Feed [LF]) are control characters that do not have visible labels. To encode these characters in a QR Code in your ASP.NET project, you need to enable the ProcessTilde property and convert the character to its three-digit ASCII value.
  • Create a new QRCode object in your ASP.NET Controller or Page Model.
  • Set ProcessTilde to true to enable the use of "~" in the data message (used to represent non-printable characters).
  • Set DataMode to QRCodeDataMode.Auto.
  • Set the Data property to "~ddd", where "ddd" is the three-digit ASCII value of the non-printable character (e.g., ~013 for [CR]).
  • Call drawBarcode() to save the QR Code to a specified path in your ASP.NET project



Note: Ensure the three-digit ASCII value is padded with leading zeros if necessary (e.g., ASCII value 5 becomes ~005, not ~5).


Encode Unicode Text in QR Code

QR Code does not support Unicode text (e.g., Thai, Arabic, Greek) by default. In ASP.NET projects, you can encode Unicode text by converting it to a byte array using UTF-8 encoding and using the Byte data mode.
  • Create a new QRCode object in your ASP.NET Controller or Page Model.
  • Set ProcessTilde to true to enable the use of "~" in the data message.
  • Set DataMode to QRCodeDataMode.Byte.
  • Convert the Unicode text to a byte array using UTF-8 encoding, then convert each byte to a three-digit string prefixed with "~".
  • Set the Data property to the combined string of these three-digit values.
  • Call drawBarcode() to save the QR Code to a specified path.



Generate GS1 QR Code in ASP.NET

GS1 QR Code is a specialized QR Code format used to encode GS1 data elements (e.g., product IDs, expiration dates) in compliance with GS1 standards. In ASP.NET projects, you can generate GS1 QR Code by setting the FNC1 property and formatting the data with Application Identifier (AI) codes.
  • Create a new QRCode object in your ASP.NET project.
  • Set FNC1 to FNC1.FNC1_1ST_POS to enable GS1 mode.
  • Set DataMode to QRCodeDataMode.Auto.
  • Set the Data property to the GS1 data string, where each AI code is enclosed in parentheses followed by the corresponding data (e.g., "(17)050101(10)ABC123").
  • Call drawBarcode() to save the GS1 QR Code to a specified path.



Note: Ensure the AI codes are correctly formatted (enclosed in parentheses) and the data length matches the requirements for each AI code.


Encode Binary Data in QR Code

Most 2D barcode symbologies, including QR Code, support binary data encoding. In ASP.NET projects, you can encode binary data (e.g., file contents, serialized objects) using the C# Barcode Generator library. The process is similar to encoding Unicode text, as binary data is converted to a byte array.


Encode Kanji Text in QR Code

Kanji text (Japanese characters) can be encoded in QR Code using the Kanji data mode, which compacts each character into 13 bits. In ASP.NET projects, you need to enable the ProcessTilde property and convert Kanji characters to their decimal equivalent in the JIS X 0208 standard.
  • Create a new QRCode object in your ASP.NET project.
  • Set ProcessTilde to true to enable the use of "~" in the data message.
  • Set DataMode to QRCodeDataMode.Kanji.
  • Set the Data property to "~9ddddd", where "ddddd" is the five-digit decimal value of the Kanji character (e.g., ~937727 for the Kanji character "点").
  • Call drawBarcode() to save the QR Code to a specified path.
Note: Ensure the Kanji characters are within the valid range (JIS X 0208) and the decimal values are five digits long (padded with leading zeros if necessary).


Customize QR Code Dimension Size in ASP.NET web app

You can customize the width (and height, as QR Code is square) of the QR Code image in your ASP.NET project using the BarcodeWidth property. This is useful for ensuring the QR Code is large enough to be scanned easily or fits within a specific UI element.
  • Create a new QRCode object in your ASP.NET Controller or Page Model.
  • Set the Data property to the desired data message.
  • Set the BarcodeWidth property to the desired width (e.g., 200 pixels).
  • Call drawBarcode() to save the customized QR Code to a specified path.
Note: Do not set the BarcodeWidth to a value that is too small (e.g., less than 100 pixels), as this may make the QR Code unreadable.


Set QR Code Quiet Zone

The quiet zone is a blank area surrounding the QR Code that is required for scanners to detect the QR Code correctly. In ASP.NET projects, you can set the quiet zone using four properties: LeftMargin, RightMargin, TopMargin, and BottomMargin.


Note: The recommended quiet zone for QR Code is at least 4 modules (pixels) on all sides. Adjust the margin values based on your project's requirements.


Advanced QR Code Features in ASP.NET Projects

ASP.NET projects may require advanced QR Code settings to meet specific functional requirements, such as error correction, version control, Structured Append mode, FNC1 mode, and ECI mode. The following sections cover these advanced settings.


QR Code Error Correction Mode

QR Code uses Reed-Solomon error correction to recover data if the QR Code is damaged or obscured. There are four error correction levels (L, M, Q, H), which determine the percentage of data that can be recovered. In ASP.NET projects, you can set the error correction level using the ECL property.
  • QRCodeECL.L: 7% data recovery (default, suitable for most ASP.NET use cases).
  • QRCodeECL.M: 15% data recovery (recommended for environments where the QR Code may be slightly damaged).
  • QRCodeECL.Q: 25% data recovery (suitable for harsh environments).
  • QRCodeECL.H: 30% data recovery (highest level, used for critical data).


QR Code Version

QR Code has 40 versions (Version 1 to Version 40), with each version increasing in size and data capacity. In ASP.NET projects, you can set the QR Code version using the Version property (from QRCodeVersion.V1 to QRCodeVersion.V40).

Note: If you do not specify a version, the library will automatically select the smallest version that can accommodate the data.


QR Code FNC1 in First Position

FNC1 (Function Character 1) in the first position indicates that the QR Code encodes data formatted according to GS1 standards. This is the same as the GS1 QR Code mode learned early. In ASP.NET projects, you can enable this mode by setting the FNC1 property to FNC1.FNC1_1ST_POS.



Summary

This page provides a comprehensive guide of generating and customizing QR Code in ASP.NET projects using C# and a C# Barcode Generator library. It covers basic QR Code generation, data encoding rules, various text format support, image customization, and advanced settings.







































Start with free trial package:








































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.