public void GetIPAddress()
{
1st method:-
string HostName = String.Empty;
HostName = System.Net.Dns.GetHostName();
Response.Write(System.Net.Dns.GetHostAddresses(HostName).GetValue(1).ToString());
2nd method:-
string IpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (IpAddress == null)
{
IpAddress = Request.ServerVariables["REMOTE_ADDR"];
}
Response.Write(IpAddress);
}