private string GetIP()
{
string IpAddress = string.empty;
1st method:-
string HostName = string.empty;
HostName = System.Net.Dns.GetHostName();
IpAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(1).ToString();
2nd method:-
string IpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (IpAddress == null)
{
IpAddress = Request.ServerVariables["REMOTE_ADDR"];
}
return IpAddress;
}