日期:2014-05-18 浏览次数:20449 次
#region 获得客户端IP private string GetClientIP() { string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (null == result || result == String.Empty) { result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } if (null == result || result == String.Empty) { result = HttpContext.Current.Request.UserHostAddress; } return result; } #endregion
------解决方案--------------------
你要获取客户端的内网IP?
------解决方案--------------------
string ip; //获取登录者的IP if (Context.Request.ServerVariables["HTTP_VIA"] != null) { ip = Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else { ip = Context.Request.ServerVariables["REMOTE_ADDR"].ToString(); }
------解决方案--------------------
Context.Request.ServerVariables["REMOTE_ADDR"].ToString();
------解决方案--------------------
看看这个