Saturday, December 20, 2014

QR Generation ASp.net MVC

The following C# ASP.net MVC project was done in Visual Studio 2012. The Zxing Dlls were obtained in
http://zxingnet.codeplex.com
After obtaining the dynamically linked libraries (dlls), It is time to create the Asp.net Web project. The figure below shows that the example was made using .Net Framework 4.5.1 while the language is C# using the ASP.net MVC Web project template.
image

Upon creating the project, Go to a the Home View files and open the index.cshtml
image
Feel free to change the text provided by the template before an initial test of the page. You can test by
pressing the button beside the browser.
image

The Page should appear with the expected content
image
Reference the Zxing Dlls
image
Browse to wherever the dlls are located. Then check if the zxing dlls were successfully referenced.
image
image
Add a class for the QR code generator. Name the class
image
The class was named QRCodeGenerator
Below is the code for that class
-----


----
Next step is to add a controller method that will call the QRCodeGenerator class's method returning the rendered image. The code of the method is seen below. In this example the Home Controller was given the method that returns the html code with the QR image of a given text
---

---
Enter the code for the cshtml. In this example the index under the Home contained the code for the Qr
Generation.

---
In my example the following code were modified after Visual Studio generated the Asp.net MVC C#
project
image
Look at the results. The solution should be ready to be built and published
image
After the publishing the page should appear on a browser. Feel free to enter a url on the textbox and
press the Get QR button
image


No comments:

Post a Comment