Search code examples
.netwindows-mobilestatic-ip-address

Uniquely identifying mobile devices over a network for webforms


I'm designing a system for mobile devices that can be assigned only to one job at a time. So I need to be able to know which mobile device is being used by accessing it's own unique static IP address or its device ID. I don't want to assign an ID myself for every machine that comes in which is why a static IP would work great.

However, in trying to retrieve the client ip address I'm retrieving the wireless router's ip or some other ip which is not the mobile device's ip.

I want to store that ip in a table and control which jobs are assigned to it. How can I accomplish this?

I've tried the following but I'm getting the wireless ip:

   var hostEntry = Dns.GetHostEntry(Dns.GetHostName());
    var ip = (
               from addr in hostEntry.AddressList
               where addr.AddressFamily.ToString() == "InterNetwork"
               select addr.ToString()
        ).FirstOrDefault();

I'd rather not set a cookie if there exists a better alternative.

TIA!


Solution

  • I got my answer from this website.

    I passed Request.ServerVariables["REMOTE_ADDR"] to the function in the above site and got the client computer name which I will use to identify each machine. IP's can change but rarely will a computer name change. Thanks for you input.