HttpContext

来源:互联网 发布:ebsco数据库怎么用 编辑:程序博客网 时间:2024/05/18 16:18

获取客户端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();//方法四(无视代理)HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
0 0