I want to get the Visitor's IP Address. For it, i'm using the following code
string hostName = Dns.GetHostName();
IPHostEntry hostEntry = Dns.GetHostEntry(hostName);
IPAddress[] ipAddress = hostEntry.AddressList;
string name = null;
for(int i=0;i
name = name + ipAddress[i].ToString()+"
";
}
Response.Write(name.ToString());
This code is showing the correct IPAddress of the local computer on localhost but as i upload this code over my server it gives me the following IPAddress not of my computer
66.63.181.68
66.63.181.93
216.45.55.186
Secondly, i use the following code
string hostName1 = Request.UserHostName.ToString();
Response.Write(hostName1.ToString());
But this is giving the IPAddress of the Main computer, I mean there are four computers, sharing the internet connection from my PC and when i visit the page from any of those computers it always give me the IP of my PC
Manoj BishtPosted Apr 1, 2009, 12:56 AM
Nipun TomarPosted Mar 31, 2009, 10:01 AM
1
if you run the code locally it will give you the local ip addresses but, code you are running on server is giving you the external ip of your computer..
2.
four computers are hidden behind main computer that is sharing the internet connection ie they seems to be one to the external network having the ip of your modem..