Link to home
Start Free TrialLog in
Avatar of Ashton Admin
Ashton Admin

asked on

QR CODE SCANNING IN ASP DOTNET

I am developing a screen, where i want to activate the camera through ASP.net screen and scan the qr code using tablet / mobile camera. The data read from the qr code will be like an authorisation of the user to complete the transaction. kindly help with the code as I tried but not working.
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Hi Ashton,

Assuming you don't want to post your existing code, I am going to post the one I have used in past.

Use this library
https://github.com/micjahn/ZXing.Net

First, I will capture the image from the camera/web cam and then upload it to your server.
Second step would be

var reader = new BarcodeReader();
//Saving the uploaded image and reading from it
var fileName =
    Path.Combine(Request.MapPath("~/Imgs"), "QRImage.jpg");
fileUpload.SaveAs(fileName);
var result = reader.Decode(new Bitmap(fileName));
Response.Write(result.Text);

Open in new window

Source: https://dotnetthoughts.net/how-to-generate-and-read-qr-code-in-asp-net/

PS: I am more than happy to check your existing code in case you can not use Zxing.

Regards,
Chinmay.
Avatar of Ashton Admin
Ashton Admin

ASKER

Hi Chinmay, thanks for the code but let me explain you as how I needit to be done

1. Develope a screen to generate QR Code stickers on the paper which are on ID card
2. on our system, we have approval screen. I want to scan qr code on the id card through a tablet and accordingly the approval is done if the code matches to the id in our system

Now when we are trying to do this, the camera on laptop / tablet is not getting activated to read the qr code from the application screen

Can you help me
Hi Ashton,

I understand the scenario. I think many of the available solution(Commercial/Free/Open Source) should be able to solve your problem.
First and foremost,

1. Are laptop/tablet camera functional? Have you tested them?
2. Which O/S you are on? Which Browser (along with version number)?
3. Have you given appropriate permissions to browser so that it can sue Camera?
3. Which solutions you have tried so far?

PS: The article I have shared has both QR Code generation logic and Checking logic. Once we sort out the camera issue that would be the next part. Develop two separate pages (you can keep this a on one page but I believe it will be easier for you to have two separate pages).

Regards,
Chinmay.
Hi

Yes we have checked and find below
1. Are laptop/tablet camera functional? Have you tested them? - Yes they are operational

2. Which O/S you are on? Which Browser (along with version number)? - OS - Windows 10 and on tablet it is Android

3. Have you given appropriate permissions to browser so that it can sue Camera? Yes we checked and gave all permissions but its blocking in GOOGLE CHROME

3. Which solutions you have tried so far? - THis is working on Mozilla but on chrome, it is blocking

THe code is working and we need solution only for Chrome.
Great :)

Please check the following:
https://support.google.com/chrome/answer/2693767?co=GENIE.Platform%3DDesktop&hl=en

and confirm that your have explicitly added required URLs to the allowed sites' list.

Second thing, open your page which requires to use Camera and after the page is completely loaded press CTRL + SHIFT + I in and check in Console. Do you see any errors or any unusual messages?
Thanks and can you advice as when we load in chrome, we always get front camera working. Is there a solution to activate back camera
Hi Ashton,

I am not sure how to do that. One way I can think of is disable the front camera - if possible at all.
PS: I don't use Chrome but there might be a setting that allows you to specify the camera. Might help to look around in the settings area.

Regards,
Chinmay.
1. Develope a screen to generate QR Code stickers on the paper which are on ID card

you could use ZXing.Net library as what Chinmay already highlighted. Tons of other solutions available at NuGet Package Library which worth to explore with. Then integrate with that generated QR Code (in general just a pic) into your output (ID Card), which could be in PDF format, image, etc.

2. on our system, we have approval screen. I want to scan qr code on the id card through a tablet and accordingly the approval is done if the code matches to the id in our system

Now when we are trying to do this, the camera on laptop / tablet is not getting activated to read the qr code from the application screen

to use your laptop camera, you may need to have another 3rd party tool/ program that constantly reading/listening the input of camera, and then transfer the signal/ image into the targeted application/ web page, etc, which I'm never done this before.

But for a simpler way, you could buy an external QR Code scanner acted as the input device, then it's pretty much easier to read the QR Code in the ID Card.

If you don't want to buy an external QR Code scanner, you can also turn your mobile device into an external QR Code scanner. for example, using GetBlue with TWedge
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.