Example #1
0
        /// <summary>
        /// 判断是否是浏览器请求
        /// </summary>
        /// <returns></returns>
        public static bool IsBrowser()
        {
            string name = WebHelpCommon.GetBrowserName();

            foreach (string item in WebEntity.Browserlist)
            {
                if (name.Contains(item))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        /// <summary>
        /// 判断是否是搜索引擎爬虫请求
        /// </summary>
        /// <returns></returns>
        public static bool IsCrawler()
        {
            bool result = HttpContext.Current.Request.Browser.Crawler;

            if (!result)
            {
                string referrer = WebHelpCommon.GetUrlReferrer();
                if (referrer.Length > 0)
                {
                    foreach (string item in WebEntity.Searchenginelist)
                    {
                        if (referrer.Contains(item))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(result);
        }