Adres IP użytkownika, który przegląda moją stronę
Chcę znać adres IP komputera klienta, tj. Adres IP użytkownika, który przegląda moją witrynę. Próbuję następującego kodu, ale zwraca on adres serwera -
public 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;
}
Jak mogę znaleźć właściwy adres IP?