IRONSOFTWAREHOME

How to Build a QR Code Scanner in Blazor

Curtis Chau
Curtis Chau
Updated: March 3, 2026

Blazor Server is a .NET web framework that runs C# on the server and pushes UI updates to the browser over a SignalR connection. IronQR integrates directly into Blazor Server, enabling server-side QR code scanning from browser-uploaded images without any JavaScript.

In this how-to guide, we'll build a Blazor Server page that accepts an image upload and decodes any embedded QR code using IronQR.

Prerequisites

  1. Visual Studio 2022 with the ASP.NET and web development workload installed
  2. A Blazor Server project targeting .NET 8 or later

Install IronQR

Install the IronQR library using the NuGet Package Manager Console in Visual Studio. Navigate to Tools > NuGet Package Manager > Package Manager Console and run:

PM > Install-Package IronQR

Alternatively, search for IronQR on NuGet and install the latest version.

Blazor Component Layout

The scanner UI uses Blazor's built-in InputFile component for browser-native file selection, a button to trigger the scan, and a paragraph to display the decoded result. No JavaScript interop is required.

Add a new Razor component Scanner.razor with the following markup:

@page "/scanner"
@using IronQr
@using IronSoftware.Drawing

<h3>QR Code Scanner</h3>

<InputFile OnChange="OnFileSelected" accept="image/*" />

<br /><br />

<button @onclick="ScanQRCode" disabled="@(qrImageSrc == null)">Scan QR Code</button>

<p>Result: @scannedText</p>
Text

Sample Input

Use the QR code below as a test image. Save it to your device, upload it via the file picker in the app, then click Scan QR Code. The decoded value should display as https://ironsoftware.com.

Sample QR code encoding https://ironsoftware.com for testing the Blazor QR scanner

Sample QR code - encodes https://ironsoftware.com

QR Code Scanning with IronQR

When a file is selected, OnFileSelected streams the browser upload to a temporary file on the server. When the scan button is clicked, ScanQRCode loads the file into an AnyBitmap, passes it to QrReader.Read(), and writes the first decoded value to scannedText, which Blazor automatically renders in the component.

Add the following @code block to Scanner.razor:

using IronQr;
using IronSoftware.Drawing;

private string? qrImageSrc;
private string scannedText = string.Empty;

private async Task OnFileSelected(InputFileChangeEventArgs e)
{
    var file = e.File;
    var tempPath = Path.Combine(Path.GetTempPath(), file.Name);
    await using var stream = file.OpenReadStream(maxAllowedSize: 10_000_000);
    await using var fs = File.Create(tempPath);
    await stream.CopyToAsync(fs);
    qrImageSrc = tempPath;
}

private async Task ScanQRCode()
{
    // Load the scanned QR code
    var inputBmp = AnyBitmap.FromFile(qrImageSrc!);
    var imageInput = new QrImageInput(inputBmp);
    var reader = new QrReader();

    // Read the scanned QR code
    var results = reader.Read(imageInput);

    // Check if a result was found
    var firstResult = results.FirstOrDefault();
    if (firstResult != null)
    {
        // Save the QR code value as a string
        scannedText = firstResult.Value;
    }
    else
    {
        scannedText = "No QR code found in the selected image.";
    }
}

InputFile.OpenReadStream streams the uploaded bytes directly to a server-side temp file. AnyBitmap.FromFile decodes the image format, and QrReader.Read returns an IEnumerable<QrResult> with one entry per QR code found. FirstOrDefault safely handles images with no QR code without throwing an exception.

Output

After selecting a QR code image and clicking Scan QR Code, the decoded value renders in the result paragraph below the controls.

Blazor QR Code Scanner using IronQR — decoded result displayed on the page

Decoded QR code value rendered in the Blazor component

Download the Project

Click here to download the complete BlazorQrScanner project.

Conclusion

IronQR integrates into a Blazor Server application with no JavaScript. InputFile provides browser-native file selection, and QrReader.Read handles decoding entirely on the server. The same pattern scales to scanning multiple QR codes per image by iterating over the full results collection instead of calling FirstOrDefault.

For more on reading QR codes and the available scan modes, see the Read QR Codes from Image and Read QR Codes with Scan Modes guides.

Frequently Asked Questions

What is the IronQR library?

IronQR is a library used to integrate QR code scanning capabilities into applications, such as a Blazor Server app, by handling server-side QR code decoding from images uploaded via the browser.

How do I integrate IronQR into a Blazor Server application?

To integrate IronQR into a Blazor Server app, you need to install the IronQR library through NuGet, use the InputFile component to handle image uploads, and use QrReader.Read() to decode QR codes server-side.

What prerequisites are required to build a QR code scanner with Blazor?

You need Visual Studio 2022 with the ASP.NET and web development workload, and a Blazor Server project targeting .NET 8 or later to build a QR code scanner.

Can I use IronQR without JavaScript in Blazor?

Yes, IronQR allows QR code scanning within a Blazor Server application without requiring JavaScript, as all decoding is handled server-side.

How does IronQR handle image uploads in Blazor?

IronQR processes image uploads by using the InputFile component to stream the file to a server-side temporary path, where it can be decoded.

How do you display the QR code result in Blazor?

Using IronQR in Blazor, the QR code result is displayed in the Blazor component's UI after decoding, by setting the result text fetched from QrReader.Read() to a property that is rendered in the UI.

Can IronQR decode multiple QR codes in a single image?

Yes, IronQR can decode multiple QR codes in a single image by iterating over the results collection instead of using FirstOrDefault().

Where can I download the complete Blazor QR Scanner project?

You can download the complete Blazor QR Scanner project from the link provided in the guide on the Iron Software website.

What does the QrReader.Read method return when decoding QR codes?

The QrReader.Read method returns an IEnumerable with one entry per QR code found, allowing you to extract decoded values.

Is the IronQR library available on NuGet?

Yes, the IronQR library is available on NuGet, and you can install it via the NuGet Package Manager Console in Visual Studio.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 74,386Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronQR
nuget.org/packages/IronQR/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronQR"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronQR to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronQR.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required