ASP.NET – How to Retrieve Device Information via Web Page

asp.netasp.net-mvcc

What we want to do is very simple

We have a check-in kiosk website (C# ASP.NET MVC), and we are trying to set up 30 kiosk stations at each building (each building is about 200 ft away from each other).
Every time a person checks in at a building, we want to collect the time and the location of the check-in. (e.g. Person-A checked in at 10:00AM at Building-B).

What I'd like to know is

The most reliable way to detect/find the location given the background below:

  • the check-in system itself is a web application
  • all the 30 devices are in one OU
  • each device has a unique machine name

Method 1 : Get the domain name with Reverse DNS

Since each device has a unique machine name, I'm currently getting the host name using reverse DNS.
The code used here is

    string IP = Request.UserHostName;
    IPAddress myIP = IPAddress.Parse(IP);
    IPHostEntry GetIPHost = Dns.GetHostEntry(myIP);
    List<string> deviceName = GetIPHost.HostName.ToString().Split('.').ToList();

This method is working for most cases, but we are aware that this method is not always reliable. We do have one case where the retrieved deviceName doesn't match the actual device name.

Method 2 : Each device specifies the location in URL

This can work. The website can take the LocationID via URL (e.g. https://sample.com/1, https://sample.com/2) and save the ID in a session or cookie. The only slight issue is that the device team will have to physically work with the device to set up each device for each URL, which I don't think is a big problem because the location won't change so often. The initial work is a bit of work for the device team because all the devices are under the same OU.

Method 3: Each device stores the location in cookie

This is similar to Method 2, and it will work. Again, the only slight issues is the initial work and the maintenance work (e.g. cookie got wiped, etc) by the device team.

Method 4: Find the actual location (i.e. latitude and longitude)

I haven't tried this yet but I should be able to use GoogleMap Geolocation to find the current location of each device, and figure out the check-in building based on the location. Unless there are some obvious issues that I'm missing, this may be more reliable and would not require any initial/maintenance work to the device team??

Which one would be a better method or are there any other methods that I should explore?

Best Answer

If the device has GPS and the browser supports the geolocation api you can use that.

If not I would use a cookie and have the site ask the user to select the location, either from a dropdown of known locations or enter a postcode etc.

Have javascript check the cookie and prompt for location if its missing. Prevent the user from using functionality without entering a location

Display the location semi prominently so that if a wrong location is selected it can be noticed and corrected.

In theory the host name or IP on a network you control should be enough to identify the location. In theory.

the problem you have is that there is that extra link between network setup and your application and the network setup isn't part of the application.

  • When IPs change your app breaks.
  • Add a new store, your app breaks
  • One site has dynamic IP? app breaks
  • Need to test the app as if it is in store X?
  • etc etc

These problems are out of your control and hard to fix.

If the app includes a setup or login step where you can get a human to enter information, then you can still have problems, but the app is self contained.

  • a user enters the wrong location, you can phone up the building and get them to reset it.
  • A new location? add it to the drop down list.
  • etc
Related Topic