Wednesday, July 30, 2008

How to retrieve visitor's IP in C# ASP.NET 2.0

string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
return clientIPAddress;

No comments: