[FIXED] C# Redirect to a new url when user scan QR CODE

Issue

I’m using QRCODE.net library to generate QR Barcode and it’s work fine. The thing is that I want that when the user scan the code with an Xamarin App, the web page which has the qr-code redirect to another url(Like WhatsApp web does). Do you have any idea to do that?

I was following this example already: http://tech.trailmax.info/2012/09/generate-qr-barcode-in-asp-net-mvc/

I have already searched a lot in Google and still haven’t found any relevant information in this regard.

Solution

you need several pre-requirements

  1. your app must be able to access a certain url embedded in your QR code after it scanned it.
  2. you need a websocket connection between the user’s browser and your page showing the QR Code, or you can keep something refreshing on that page, like an auto-refreshed iframe or an interval js script

then the solution flow will be

  1. page shows the QR Code with an embedded url contains an unique key, meanwhile store the unique key on the server, tag the key as “not scanned”, establishes the websocket or starts the interval refresh
  2. app scans the QR, and sends a request to the embedded url
  3. the embedded url recieves the request with the unique key, then find the key stored on server and tag it as “scanned”
  4. if you use websocket, then detect the change of the key’s status, push a message to client browser to redirect to wherever you want. if you use interval refresh, then when re-load, just pull the status of current key, if status is “scanned” then redirect

Answered By – Ray H

Answer Checked By – Willingham (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published