public static string getclientIP()
{
string result= string.Empty;
string ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
int le = ipRange.Length - 1;
result = ipRange[0];
}
else
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
return result;
}
If u run u will get the ip address 127.0.0.1.Here 127.0.0.1 is localhost. this means you are working on your PC. If you try other PC to use your app, you will get a different ip address.what i mean is host your application in your IIS or on your server and another pc must use your application. with that, you will get a different IP. 127.0.0.1 is localhost, meaning, current IP address.