core mvc application using c#.net.
Please check my previous article ASP.NET Core Tutorial: Generate QR Codes with C#.NET.
You may also like these articles:
- Asp.Net Core 10: Access/Get RequestQuery String Value In Controller Using C#.Net
- Bind Webgrid (GridView) with Entity Framework, Asp.net Core MVC, C#, SQL
- Download File From wwwroot Folder Asp.Net Core 10 Using C#
- Render PartialView in Asp.Net Core MVC Using C#.Net
- Move or Add Multiple Selected Items Between ListBox Controls (C# & VB.NET)
- Verify if an Excel File is Password Protected/Encrypted in C#, VB.Net
In this article we will use asp.net core 10 mvc application with C#.net. So first we will install NuGet package named as NetBarCode.
using Microsoft.AspNetCore.Mvc;
using NetBarcode;
namespace BarCode.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
var barcode = new Barcode("123456789", true);
string savePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "barcode.png");
barcode.SaveImageFile(savePath, ImageFormat.Png);
return View();
}
}
}
In above code i have created object for BarCode and added value. This value is the data for which we are going to generate the barcode. In this if you want to display the barcode value also you need to pass true. In next line i have saved the barcode image to wwwroot folder. Now create a view and add the below code in it.@{
ViewData["Title"] = "Bar Code";
}
<div style="text-align:left;">
<img src="barcode.png" style="width:200px;height:200px" />
</div>
In above code I have bind the generated barcode image to img tag. Now we have done. Run the code to check the output.

