Skip to content

Commit

Permalink
Fixes #11183
Browse files Browse the repository at this point in the history
  • Loading branch information
Shazwazza committed Sep 25, 2021
1 parent 7f2d2b3 commit 48b48f0
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/Umbraco.Web.Website/Routing/UmbracoRouteValueTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,7 @@ public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext

IPublishedRequest publishedRequest = await RouteRequestAsync(umbracoContext);

umbracoRouteValues = await _routeValuesFactory.CreateAsync(httpContext, publishedRequest);

if (!umbracoRouteValues?.PublishedRequest?.HasPublishedContent() ?? false)
{
// No content was found, not by any registered 404 handlers and
// not by the IContentLastChanceFinder. In this case we want to return
// our default 404 page but we cannot return route values now because
// it's possible that a developer is handling dynamic routes too.
// Our 404 page will be handled with the NotFoundSelectorPolicy
return null;
}
umbracoRouteValues = await _routeValuesFactory.CreateAsync(httpContext, publishedRequest);

// now we need to do some public access checks
umbracoRouteValues = await _publicAccessRequestHandler.RewriteForPublishedContentAccessAsync(httpContext, umbracoRouteValues);
Expand All @@ -155,6 +145,18 @@ public override async ValueTask<RouteValueDictionary> TransformAsync(HttpContext
return HandlePostedValues(postedInfo, httpContext);
}

UmbracoRouteResult? routeResult = umbracoRouteValues?.PublishedRequest?.GetRouteResult();

if (!routeResult.HasValue || routeResult == UmbracoRouteResult.NotFound)
{
// No content was found, not by any registered 404 handlers and
// not by the IContentLastChanceFinder. In this case we want to return
// our default 404 page but we cannot return route values now because
// it's possible that a developer is handling dynamic routes too.
// Our 404 page will be handled with the NotFoundSelectorPolicy
return null;
}

// See https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.routing.dynamicroutevaluetransformer.transformasync?view=aspnetcore-5.0#Microsoft_AspNetCore_Mvc_Routing_DynamicRouteValueTransformer_TransformAsync_Microsoft_AspNetCore_Http_HttpContext_Microsoft_AspNetCore_Routing_RouteValueDictionary_
// We should apparenlty not be modified these values.
// So we create new ones.
Expand Down

0 comments on commit 48b48f0

Please sign in to comment.