示例#1
0
        /// <inheritdoc />
        public async Task <IPublishedRequest> UpdateRequestAsync(IPublishedRequest request, IPublishedContent?publishedContent)
        {
            // store the original (if any)
            IPublishedContent?content = request.PublishedContent;

            IPublishedRequestBuilder builder = new PublishedRequestBuilder(request.Uri, _fileService);

            // set to the new content (or null if specified)
            builder.SetPublishedContent(publishedContent);

            // re-route
            await RouteRequestInternalAsync(builder);

            // return if we are redirect
            if (builder.IsRedirect())
            {
                return(BuildRequest(builder));
            }

            // this will occur if publishedContent is null and the last chance finders also don't assign content
            if (!builder.HasPublishedContent())
            {
                // means the engine could not find a proper document to handle 404
                // restore the saved content so we know it exists
                builder.SetPublishedContent(content);
            }

            if (!builder.HasDomain())
            {
                FindDomain(builder);
            }

            return(BuildRequest(builder));
        }
示例#2
0
        /// <inheritdoc />
        public async Task <IPublishedRequestBuilder> CreateRequestAsync(Uri uri)
        {
            // trigger the Creating event - at that point the URL can be changed
            // this is based on this old task here: https://issues.umbraco.org/issue/U4-7914 which was fulfiled by
            // this PR https://github.com/umbraco/Umbraco-CMS/pull/1137
            // It's to do with proxies, quote:

            /*
             *  "Thinking about another solution.
             *  We already have an event, PublishedContentRequest.Prepared, which triggers once the request has been prepared and domain, content, template have been figured out -- but before it renders -- so ppl can change things before rendering.
             *  Wondering whether we could have a event, PublishedContentRequest.Preparing, which would trigger before the request is prepared, and would let ppl change the value of the request's URI (which by default derives from the HttpContext request).
             *  That way, if an in-between equipement changes the URI, you could replace it with the original, public-facing URI before we process the request, meaning you could register your HTTPS domain and it would work. And you would have to supply code for each equipment. Less magic in Core."
             */

            // but now we'll just have one event for creating so if people wish to change the URL here they can but nothing else
            var creatingRequest = new CreatingRequestNotification(uri);
            await _eventAggregator.PublishAsync(creatingRequest);

            var publishedRequestBuilder = new PublishedRequestBuilder(creatingRequest.Url, _fileService);

            return(publishedRequestBuilder);
        }