穿过代理服务器取远程用户真实IP地址
- public static string GetIP()
- {
- string str = "";
- //穿过代理服务器取远程用户真实IP地址:
- if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
- {
- str = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
- }
- else
- {
- str = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
- }
- return str;
- }