hello
I have a problem with SetContentLastChanceFinder.
I've defined a custom route (via MapControllerRoute) that calls a controller to render a view for content that does not exist as an umbraco node.
The problem is that Umbraco triggers first the SetContentLastChanceFinder and assigns the published content to my 404 page, and after that goes to the routing and the correct controller.
In that controller, CurrentPage has the correct value, but in the view, the Umbraco.AssignedContentItem is my 404 page
The SetContentLastChanceFinder is configured like this
public static IUmbracoEndpointBuilderContext UseMyEndpoints(this IUmbracoEndpointBuilderContext app)
{
app.EndpointRouteBuilder.MapControllerRoute(
"HtmlDetails",
"{language}/search/details/{id}",
new { Controller = "DetailPage", Action = "HtmlDetail" })
.ForUmbracoPage(FindContent);
return app;
}
private static IPublishedContent FindContent(ActionExecutingContext actionExecutingContext)
{
var myService = actionExecutingContext.HttpContext.RequestServices.GetRequiredService<IMyService>();
var dpSearchPage = myService.GetSearchPage();
return dpSearchPage;
}
In the startup, I have this
app.UseUmbraco()
.WithMiddleware(u =>
{
if (includeBackoffice)
{
u.UseBackOffice();
}
u.UseWebsite();
})
.WithEndpoints(u =>
{
u.UseMyEndpoints();
if (includeBackoffice)
{
u.UseInstallerEndpoints();
u.UseBackOfficeEndpoints();
}
//This part only if we need to minify javascript in the frontend,
//if just APIs we can remove this part
else
{
u.UseUmbracoRuntimeMinificationEndpoints();
}
u.UseWebsiteEndpoints();
});
How can I be sure that the Umbraco.AssignedContentItem is correctly set ?
And why the SetContentLastChanceFinder is called before the routing ?
When I enter a URL that doesn't exist I have the correct 404 return code, but with the routing, even if it goes first on the SetContentLastChanceFinder and if the Umbraco.AssignedContentItem is the cutom 404 page, the return code is 200
SetContentLastChanceFinder and Custom route
hello I have a problem with SetContentLastChanceFinder.
I've defined a custom route (via MapControllerRoute) that calls a controller to render a view for content that does not exist as an umbraco node.
The problem is that Umbraco triggers first the SetContentLastChanceFinder and assigns the published content to my 404 page, and after that goes to the routing and the correct controller. In that controller, CurrentPage has the correct value, but in the view, the Umbraco.AssignedContentItem is my 404 page
The SetContentLastChanceFinder is configured like this
The routing is defined like this
In the startup, I have this
How can I be sure that the Umbraco.AssignedContentItem is correctly set ? And why the SetContentLastChanceFinder is called before the routing ?
When I enter a URL that doesn't exist I have the correct 404 return code, but with the routing, even if it goes first on the SetContentLastChanceFinder and if the Umbraco.AssignedContentItem is the cutom 404 page, the return code is 200
Hi - did you figure this one out?
not yet
is working on a reply...