System.Web.HttpContext.Current.Request.UserHostAddress;

后端 未结 3 883
独厮守ぢ
独厮守ぢ 2020-12-18 10:05

I am using the following code to obtain the user I.P. address but something strange is happening. I am, receiving the same ip address every time no matter if I am on my desk

3条回答
  •  孤城傲影
    2020-12-18 10:42

    see this link http://thepcspy.com/read/getting_the_real_ip_of_your_users/

            // Look for a proxy address first
            _ip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
    
            // If there is no proxy, get the standard remote address
            if (_ip == null || _ip.ToLower() == "unknown")
                _ip = Request.ServerVariables["REMOTE_ADDR"];
    

提交回复
热议问题