دوستان این کدمه:

private string GetIP        {
get
{
string IP = "";
NameValueCollection nv = HttpContext.Current.Request.ServerVariables;
string _ProxyIP = nv["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(_ProxyIP))
IP = nv["REMOTE_ADDR"];
else
{
_ProxyIP = (_ProxyIP.Contains(",")) ? _ProxyIP = _ProxyIP.Split(',')[0] : _ProxyIP;
IP = (_ProxyIP.Contains(":")) ? _ProxyIP.Split(':')[0] : _ProxyIP;
}
IP = IP.Trim();
return IP == "::1" ? "127.0.0.1" : IP;
}
}


ولی با این کد نتیجه نگرفتم و خطای object not reference داد.