I am working on an MVC solutions and I want to generate QR code that contain more details about someone and save it's data automatically when scan QR , How can I do that in MVC?
To generate QR code that contain more details about someone and save it's data automatically when scan QR, you should follow the below steps in details:
You should create GeneratevCard that accept parameters such as : FirstName ,LastName,MobileNo ,Email and OrganizationName and return byte[]
public static byte[] GeneratevCard(string FirstName, string LastName, string MobileNo, string Email,string OrganizationName) { StringBuilder vCardBuilder = new StringBuilder(); vCardBuilder.AppendLine("BEGIN:VCARD"); vCardBuilder.AppendLine("VERSION:3.0"); vCardBuilder.AppendLine($"FN:{FirstName} {LastName}"); vCardBuilder.AppendLine($"N:{LastName};{FirstName};;;"); vCardBuilder.AppendLine($"TEL;TYPE=CELL:{MobileNo}"); vCardBuilder.AppendLine($"EMAIL:{Email}"); vCardBuilder.AppendLine($"ORG:{OrganizationName}"); vCardBuilder.AppendLine("END:VCARD"); return GenerateQR(vCardBuilder.ToString()); }
Call method in your controller
var QR = QrGenerator.GeneratevCard("Moahamed", "Elsakhawy", "0096654039XXXX", "melsakhawyXX@gmail.com", "CompanySample"); ViewBag.QrCodeBase64 = Convert.ToBase64String(QR);
Call ViewBag with name QrCodeBase64 in frontend
<div class="text-center"> <h5>@Resources.Labels.MobileInfo</h5> <img id='base64image' src='data:image/jpeg;base64, @ViewBag.QrCodeBase64' width="150" class="img-thumbnail" /> </div>
Scan QR Code using Mobile Camera .
Great, the QR code has been working properly.
1.1k questions
673 answers
454 comments
193k users
Related Activities
Categories
Most popular tags