.NET CORE API
Generate QR Code in 4 Lines of Code
A QR code is a computer-readable identification that contains data about the item to which it is attached. The article demonstrates how to return the QR Code image as a response from .Net Core API.
Published in
3 min readAug 21, 2020
QR-Code Live Demo
Prerequisites
- Visual Studio or Visual Studio Code already installed
- Install the below package, i.e., “QRCoder” via NuGet package manager.
Install-Package QRCoder
Let’s Start
The “QRCoder” DLL helps to generate QR code with just four lines of code in C#.
4 Lines of Code Snippet
QRCodeGenerator qrGenerator = new QRCodeGenerator();QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q);QRCode qrCode = new QRCode(qrCodeData);Bitmap qrCodeImage = qrCode.GetGraphic(20);