获取用户IP

public static string GetIP()
        {
            string ip;
            if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
            {
                ip = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
            }
            else
            {
                ip = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            }
            return ip;

        }

 

转载自:https://wenda.so.com/q/1367574009062436

posted @ 2019-04-04 09:51  大冉啊  阅读(133)  评论(0编辑  收藏  举报