Hi! Is there a way to identify what device the user is using in accessing the website?
I am using ASP.Net/C#.Net. Aside from getting the HostName and IP_Address. I already know how to get the Host Name and IP, but the problem is there's a big possibility that the user might change it.
I came up with detecting the Hard disk ID which the user cannot really change it. But the problem is, what if the user is using other gadgets like iPhone, iPad or other devices aside from Laptops and Desktops...
Loading
Suthish NairPosted Sep 10, 2013, 4:03 AM
If the server is behind the firewall then use Request.ServerVariables("HTTP_X_FORWARDED_FOR").
Now this will return a collection of IP address, the first entry in the list will be the actual IP address.
If you run this code on local it will always return localhost ot 127.0.0.1. Publish the application to server and try.
Request.ServerVariables have lots of other information, just put a Add Watch and check..
Ayin RiveraPosted Jan 9, 2014, 11:15 PM
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] == null) { Session["MacAddress"] = Request.ServerVariables["REMOTE_ADDR"]; } else { Session["MacAddress"] = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; }
Problem:
When the user is using a proxy server to access the website, what I am getting is the ip of proxy server and not the real IP of the user. Is there any way to get the real IP of the user?
Ayin RiveraPosted Nov 18, 2013, 2:21 AM
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] == null)
{
Session["MacAddress"] = Request.ServerVariables["REMOTE_ADDR"];
}
else
{
Session["MacAddress"] = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
}
Suthish NairPosted Sep 11, 2013, 9:08 AM
Ayin RiveraPosted Sep 11, 2013, 5:41 AM
Ayin RiveraPosted Sep 9, 2013, 9:42 PM
Manish TewatiaPosted Sep 5, 2013, 4:22 AM
Is your application hosted on the web server or you running it locally....?
Ayin RiveraPosted Sep 5, 2013, 3:32 AM
HttpRequest ReqIP = base.Request;
Session["IP_Address"] = ReqIP.UserHostAddress;
Session["HostName"] = ReqIP.UserHostName;
At first, it gives me the correct IP Address. But after number of tries, it only gives me :127.0.0.1
I don't know what happened. 0_o?
?What I need is the IP Address of the user accessing the Website across the Network. I also tried using some codes, but it only return the server IP and Hostname. :(
Manish TewatiaPosted Sep 5, 2013, 12:27 AM
Whenever you get a request from any user the "userAgent" is always there which contains the device type like if the user browse your site from Iphone in that case the "userAgent" contains Iphone.... So, you can use "userAgent" to identify the user device.
Thank you