方法一
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();
方法四(无视代理)
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
一起学习,我试了,可以... |