asp.net判断是否代理

 /// <summary>
        /// 判断访问者是不是用代理访问,如果是返回true,否则false
        /// </summary>
        /// <returns></returns>
        public static bool checkIpPro()
        {
            bool bl = false;
            string FY_IP = string.Empty;
            FY_IP = HttpContext.Current.Request.ServerVariables["ALL_HTTP"].ToLower();
            if (FY_IP.IndexOf("proxy") > 0 || FY_IP.IndexOf("http_via") > 0 || FY_IP.IndexOf("http_pragma") > 0 || HttpContext.Current.Request.ServerVariables["HTTP_PROXY_CONNECTION"] != "" ||
                HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != "" || HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT_VIA"] != "" ||
                HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "" || HttpContext.Current.Request.ServerVariables["HTTP_PROXY_CONNECTION"] != "" ||
                HttpContext.Current.Request.ServerVariables["HTTP_CACHE_CONTROL"] != "" || HttpContext.Current.Request.ServerVariables["HTTP_CACHE_INFO"] != "")
            {
                bl = true;
            }
            return bl;
        }

 

posted @ 2014-11-20 10:35  瞭望者  阅读(532)  评论(0编辑  收藏  举报