public static string GetRealIp()
{ string ip=""; try { HttpRequest request = HttpContext.Current.Request; if (request.ServerVariables["http_VIA"] != null) { ip = request.ServerVariables["http_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); } else { ip = request.UserHostAddress; } } catch (Exception e) { throw e; } return ip; } |
|