I use this in a Windows EXE program:
string strHostName = System.Net.Dns.GetHostName();
string strIPAddress = "";
System.Net.IPAddress[] objAddressList = System.Net.Dns.GetHostEntry(strHostName).AddressList;
for (x = 0; x <= objAddressList.GetUpperBound(0); x++)
{
if (objAddressList[x].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
strIPAddress = objAddressList[x].ToString();
break;
}
}
I found this via Google Search at
get ip address in asp page - client side[
^]
Response.Write("Local Machine Host name is "+Dns.GetHostName()+"<br>");
string hostname = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostByName(hostname);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
Response.Write(string.Format("IP Address {0}: {1} ", i, addr[i].ToString()) + "<br>");
}
And some good tips at
A Gotcha Identifying the User's IP Address[
^]