├── ASP.NET-Core-QRCoder ├── Controllers │ └── QRCoderController.cs ├── Views │ └── QRCoder │ │ ├── GenerateFile.cshtml │ │ ├── Index.cshtml │ │ └── ViewFile.cshtml └── wwwroot │ └── qrr │ ├── file-88ef.qrr │ └── file-ae65.qrr ├── README.md └── qrcoder-aspnet-core.png /ASP.NET-Core-QRCoder/Controllers/QRCoderController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Threading.Tasks; 7 | using Microsoft.AspNetCore.Mvc; 8 | using QRCoder; 9 | 10 | namespace pjax.Controllers 11 | { 12 | public class QRCoderController : Controller 13 | { 14 | public IActionResult Index() 15 | { 16 | return View(); 17 | } 18 | 19 | [HttpPost] 20 | public IActionResult Index(string qrText) 21 | { 22 | QRCodeGenerator qrGenerator = new QRCodeGenerator(); 23 | QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q); 24 | QRCode qrCode = new QRCode(qrCodeData); 25 | Bitmap qrCodeImage = qrCode.GetGraphic(20); 26 | 27 | return View(BitmapToBytes(qrCodeImage)); 28 | } 29 | 30 | private static Byte[] BitmapToBytes(Bitmap img) 31 | { 32 | using (MemoryStream stream = new MemoryStream()) 33 | { 34 | img.Save(stream, System.Drawing.Imaging.ImageFormat.Png); 35 | return stream.ToArray(); 36 | } 37 | } 38 | 39 | public IActionResult GenerateFile() 40 | { 41 | return View(); 42 | } 43 | 44 | [HttpPost] 45 | public IActionResult GenerateFile(string qrText) 46 | { 47 | QRCodeGenerator qrGenerator = new QRCodeGenerator(); 48 | QRCodeData qrCodeData = qrGenerator.CreateQrCode(qrText, QRCodeGenerator.ECCLevel.Q); 49 | string fileGuid = Guid.NewGuid().ToString().Substring(0, 4); 50 | qrCodeData.SaveRawData("wwwroot/qrr/file-" + fileGuid + ".qrr", QRCodeData.Compression.Uncompressed); 51 | 52 | QRCodeData qrCodeData1 = new QRCodeData("wwwroot/qrr/file-" + fileGuid + ".qrr", QRCodeData.Compression.Uncompressed); 53 | QRCode qrCode = new QRCode(qrCodeData1); 54 | Bitmap qrCodeImage = qrCode.GetGraphic(20); 55 | return View(BitmapToBytes(qrCodeImage)); 56 | } 57 | 58 | public IActionResult ViewFile() 59 | { 60 | List> fileData=new List>(); 61 | KeyValuePair data; 62 | 63 | string[] files = Directory.GetFiles("wwwroot/qrr"); 64 | foreach (string file in files) 65 | { 66 | QRCodeData qrCodeData = new QRCodeData(file, QRCodeData.Compression.Uncompressed); 67 | QRCode qrCode = new QRCode(qrCodeData); 68 | Bitmap qrCodeImage = qrCode.GetGraphic(20); 69 | 70 | Byte[] byteData = BitmapToBytes(qrCodeImage); 71 | data = new KeyValuePair(Path.GetFileName(file), byteData); 72 | fileData.Add(data); 73 | } 74 | 75 | return View(fileData); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /ASP.NET-Core-QRCoder/Views/QRCoder/GenerateFile.cshtml: -------------------------------------------------------------------------------- 1 | @model Byte[] 2 | @{ 3 | Layout = null; 4 | } 5 | 6 | 7 | 8 | 9 | 10 | 11 | Implementing QRCoder in ASP.NET Core - Create QR Code File 12 | 88 | 89 | 90 |
91 |
92 |

Implementing QRCoder in ASP.NET Core - Create QR Code File

93 |

94 | Read the tutorial on YogiHosting » 95 | 96 |

97 |
98 | @using (Html.BeginForm(null, null, FormMethod.Post)) 99 | { 100 | 101 | 102 | 103 | 106 | 109 | 110 | 111 | 114 | 115 | 116 |
104 | 105 | 107 | 108 |
112 | 113 |
117 | } 118 |
119 | @{ 120 | if (Model != null) 121 | { 122 |

QR Code file Successfully Generated

123 | 124 | } 125 | } 126 |
127 |
128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /ASP.NET-Core-QRCoder/Views/QRCoder/Index.cshtml: -------------------------------------------------------------------------------- 1 | @model Byte[] 2 | @{ 3 | Layout = null; 4 | } 5 | 6 | 7 | 8 | 9 | 10 | 11 | Implementing QRCoder in ASP.NET Core - Create QR Code 12 | 88 | 89 | 90 |
91 |
92 |

Implementing QRCoder in ASP.NET Core - Create QR Code

93 |

94 | Read the tutorial on YogiHosting » 95 | 96 |

97 |
98 | @using (Html.BeginForm(null, null, FormMethod.Post)) 99 | { 100 | 101 | 102 | 103 | 106 | 109 | 110 | 111 | 114 | 115 | 116 |
104 | 105 | 107 | 108 |
112 | 113 |
117 | } 118 |
119 | @{ 120 | if (Model != null) 121 | { 122 |

QR Code Successfully Generated

123 | 124 | } 125 | } 126 |
127 |
128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /ASP.NET-Core-QRCoder/Views/QRCoder/ViewFile.cshtml: -------------------------------------------------------------------------------- 1 | @model List> 2 | @{ 3 | Layout = null; 4 | } 5 | 6 | 7 | 8 | 9 | 10 | 11 | Implementing QRCoder in ASP.NET Core - View QR Code Files 12 | 96 | 97 | 98 |
99 |
100 |

Implementing QRCoder in ASP.NET Core - View QR Code Files

101 |

102 | Read the tutorial on YogiHosting » 103 | 104 |

105 |
106 | 107 | 108 | @foreach (KeyValuePair k in Model) 109 | { 110 | 111 | 115 | 116 | } 117 | 118 |
112 | 113 | @k.Key 114 |
119 |
120 |
121 |
122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /ASP.NET-Core-QRCoder/wwwroot/qrr/file-88ef.qrr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yogyogi/QRCoder-implemented-in-ASP.NET-Core/405bd4d09202082cc0c692bb948cb3a42ee0a318/ASP.NET-Core-QRCoder/wwwroot/qrr/file-88ef.qrr -------------------------------------------------------------------------------- /ASP.NET-Core-QRCoder/wwwroot/qrr/file-ae65.qrr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yogyogi/QRCoder-implemented-in-ASP.NET-Core/405bd4d09202082cc0c692bb948cb3a42ee0a318/ASP.NET-Core-QRCoder/wwwroot/qrr/file-ae65.qrr -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QRCoder Implemented in ASP.NET Core 2 | QRCoder Implemented in ASP.NET Core 3 | 4 | ![QRCoder Implementation](https://raw.githubusercontent.com/yogyogi/QRCoder-implemented-in-ASP.NET-Core/master/qrcoder-aspnet-core.png) 5 | 6 | This repository is made for anyone who wants to generate QRCodes in their [ASP.NET Core](https://www.yogihosting.com/category/aspnet-core/) Application. 7 | 8 | # I have Tested it, works perfectly with ASP.NET Core MVC 2.0, 2.2, 3.1 & 5.0 9 | 10 | I have also explained the full working of the codes at - [How to easily implement QRCoder in ASP.NET Core using C#](https://medium.com/free-code-camp/how-to-easily-implement-qrcoder-in-asp-net-core-using-c-10c4aa857e84) 11 | 12 | Star this respository and Enjoy Coding! 13 | 14 | ## Want to support me ? 15 | 16 | Your support of every $5 will be a great reward for me to carry on my work. Thank you! 17 | 18 | Buy Me A Coffee 19 | Paypal Me 20 | 21 | -------------------------------------------------------------------------------- /qrcoder-aspnet-core.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yogyogi/QRCoder-implemented-in-ASP.NET-Core/405bd4d09202082cc0c692bb948cb3a42ee0a318/qrcoder-aspnet-core.png --------------------------------------------------------------------------------