Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to scan barcode Through mobile camera on website

when we open web and then click on Scan automatically camera will on mobile and start scan
i want that scan value in textbox

What I have tried:

<pre>
i don't know how to do it . i just search out a web and mention it ,
kindly check there what i have need
Posted
Updated 15-Mar-21 4:12am
Comments
Dave Kreskowiak 13-Mar-21 1:59am    
You can't do that. All code in ASP.NET runs on the server, not the client. The server has no access to the browser, or the client hardware at all.

1 solution

As Dave said, you cannot access the camera from the server-side code. Which means you need to access it from Javascript.

Fortunately, there's an API for that:
MediaDevices.getUserMedia() - Web APIs | MDN[^]

It has fairly broad support, but you will need to make sure your site is served via HTTPS to use it.

And before you ask, no, there is no way to bypass the permission prompt.

Once you have the image, you will need to scan it for a barcode. You can either send the image to the server to do that, or use a client-side library. Google will find several examples - eg: QuaggaJS[^], zxing-js[^], etc.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900