ASP.NET source Code for generating QR Code barcode

Discussion in 'ASP.NET / ASP.NET Core' started by paula pauline, Dec 28, 2012.

  1. Hi, guys. I am in a hurry to get some right source code for generating QR Code in ASP.NET. I copied a ASP.NET QR Code Generator's code to my program. It did not work. I do not know the reason why this happyed. Any one has source code? Thank you for your help!!!
     
  2. I know you were in a hurry so perhaps this response is too late. My personal preference for embedding QR barcodes in web pages is to use the Google chart API. Here's one:

    [​IMG]

    Generated by this html (there's no requirement for a library or assembly or anything else to be installed on the DASP server):
    Code:
    <img src="https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=Hello%20world&amp;choe=UTF-8">
    As I said the Google chart API would be my choice but are loads of others. Take a look here as a starter for 10(ish): http://stackoverflow.com/questions/3793799/qr-code-generation-in-asp-net-mvc
     
  3. mjp

    mjp

    +1 for Google chart (pun intended).
     
  4. are you asking for VB.NET or C# codes? I just have some C# codes here and I have already tested those them. It works.
     
  5. Acctually, you should first download their ASP.NET barcode generator library in your program. Then you can use the sample code.
     
  6. I am using the google chart API and it is working fine.

    All I want to know is how do I change the filename of the outputted qr code??

    When I have 2 or 3 QR codes on the one page, I want to right click on image and save them with a unique name... each one by default is named chart.png...

    I am using C# - there are heaps of php examples out there, but nothing for c#

    can anyone help?
     
  7. The request sounds simple enough but as you've found it isn't that simple with the Google chart API because when you create and put a QR code URL into an IMG tag in HTML margkup, at browser page render / runtime the generated QR code IMG content gets generated remotely by the Google server(s) and the IMG is dynamically created and rendered. In short you have zero control over the resulting filename for a right click / save UX in the browser.

    All is not lost however because one approach where you can actually control the filename of a QR code generated by the Google Chart API is to use a server side C# WebClient call to return a raw stream to the Google Chart API generated QR code image data and then return that stream as a downloadable attachment in a HTTP response. If you were to follow this route, you would need a html element on your page to initiate the image download though (e.g. a button) so I guess it might change the UX of your page - in other words, this is not controlling the right click / save filename user experience in the browser but it is 100% giving you control of the filename for the downloaded QR code.

    You might even go further with this approach and enable a user to enter their own QR code text, specify the resulting image size and preferred filename for download by implementing a complete html form to capture all of the user input params. There are a few fair websites that already implement this type of UX using the Google Chart API at the back end.
     
  8. i know this software, i think those third party softwares are designed for the professionals and it's too expensive for me who just use it only once, so do you know some ways to do so without any cost?
     
  9. - this o_O
     
    martino and mjp like this.
  10. andyadams

    andyadams Guest

    Hi,i just did it yesterday and generated a QR code in ASP .NET by myself.Here is the helpful page that i found,.which tells me how to generate a QR code in ASP.NET: [Link to an unnecessary and unnecessarily expensive product removed.] I hope it's also useful for you.
     
  11. mjp

    mjp

    Nothing brings out the spammers like a barcode/QR code generator post. A cynical person might think they even start the threads, but obviously I'm not that cynical.
     
    martino likes this.

Share This Page