Exemplo n.º 1
0
        private void ProcessOutputCache(RequestContext requestContext)
        {
            if (HttpContext.Current == null)
                return;

            var user = requestContext.HttpContext.User;
            if (user == null || user.Identity.IsAuthenticated)
                return;

            ICacheManager cacheManager = RouteExtensions.ResolveService<ICacheManager>(requestContext.RouteData);
            if (adhereToConfig && !cacheManager.Enabled)
                return;

            var page = new OutputCachedPage(cacheManager.GetOutputCacheParameters());
            page.ProcessRequest(HttpContext.Current);
            cacheManager.AddCacheInvalidation(requestContext.CurrentPage(), HttpContext.Current.Response);
        }
Exemplo n.º 2
0
        public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
        {
            ContentItem item;

            Debug.WriteLine("GetVirtualPath for values: " + values.ToQueryString());

            values = new RouteValueDictionary(values);

            // try retrieving the item from the route values
            if (!TryConvertContentToController(requestContext, values, ContentItemKey, out item))
            {
                // no item was passed, fallback to current content item
                item = requestContext.CurrentItem();

                if (item == null)
                    // no item = no play
                    return null;

                if (!RequestedControllerMatchesItemController(values, item))
                    // someone's asking for a specific controller so we let another route handle it
                    return null;
            }

            if (item.IsPage)
                return ResolveContentActionUrl(requestContext, values, item);

            // try to find an appropriate page to use as path (part data goes into the query strings)
            ContentItem page = values.CurrentItem<ContentItem>(ContentPageKey, engine.Persister);
            if (page != null)
                // a page parameter was passed
                return ResolvePartActionUrl(requestContext, values, page, item);

            page = requestContext.CurrentPage<ContentItem>();
            if (page != null && page.IsPage)
                // next use the current page
                return ResolvePartActionUrl(requestContext, values, page, item);

            page = item.ClosestPage();
            if (page != null && page.IsPage)
                // fallback to finding the closest page
                return ResolvePartActionUrl(requestContext, values, page, item);

            // can't find a page, don't link
            return null;
        }