获取IP 地址的方法。
//方法一
<%=HttpContext.Current.Request.UserHostAddress %>
//方法二
<%=HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] %>
//方法三
<% string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress =
System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString(); %>
<%=clientIPAddress%>
//方法四(无视代理)
<%=HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] %>
正确应用在项目中,
//方法一 :115.238.160.198 本地客户端IP地址
//方法二 :115.238.160.198 本地客户端IP地址
//方法三 :223.4.92.131 服务器IP地址
//方法四(无视代理):没有