Пример #1
0
        public static bool IsRequestShouldBePrerendered(RequestParams requestParams, PrerenderConfig config)
        {
            // Check '_escaped_fragment_' query string parameter

            if (!string.IsNullOrEmpty(requestParams.RequestUri.Query) &&
                requestParams.RequestUri.Query.Contains(EscapedQueryStringParameterName))
            {
                return(true);
            }

            // Check ignore file extentions
            string extention = Path.GetExtension(requestParams.RequestUri.AbsoluteUri);

            if (!string.IsNullOrEmpty(extention))
            {
                for (int i = 0; i < config.Configuration.IgnoreExtentions.Count; i++)
                {
                    PrerenderSection.IgnoreExtentionElement extentionElm = config.Configuration.IgnoreExtentions[i];
                    if (string.Equals(extentionElm.Extention, extention, StringComparison.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }
            }

            // Check crawler user agent
            if (requestParams.UserAgent != null)
            {
                for (int i = 0; i < config.Configuration.Crawlers.Count; i++)
                {
                    PrerenderSection.CrawlerElement crawlerElm = config.Configuration.Crawlers[i];
                    if (crawlerElm.IsMatch(requestParams.UserAgent))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #2
0
 public PrerenderServiceConfiguration()
     : this(PrerenderConfig.GetCurrent())
 {
 }
Пример #3
0
 public PrerenderServiceConfiguration(PrerenderConfig config)
 {
     _config = config;
 }
Пример #4
0
 public void Init()
 {
     _config = new PrerenderConfig();
     _config.Configuration = new PrerenderSection();
 }