I am trying to obtain the local machine IP address of users who visit my website. Below is the code that I have used:
string ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ipAddress))
{
string[] addresses = ipAddress.Split(',');
if (addresses.Length != 0)
{
stradd = addresses[0];
}
else
{
stradd = ipAddress;
}
}
else
{
stradd = Request.ServerVariables["REMOTE_ADDR"].ToString();
}
hostName = Dns.GetHostByAddress(stradd).HostName;
The above code retrieves the IP address and name of the service provider, but I actually want the local IP address of the user's device. Is it possible to retrieve the user's local IP address? Any help would be appreciated.