I am using a content finder (IContentLastChanceFinder) just fine for serving out a custom page for “Not found”/404 content requests. However, I am struggling to work out how to use a custom 404 page for static files (missing images etc).
That didn’t work, so I tried the following with my custom path:
UseStatusCodePagesWithReExecute("/notfound");
That didn’t work either. I'm not really sure if its because Umbraco core has already registered middleware and I can’t override/supersede that or that my registration sequence is incorrect (i did try things in different order), so any thoughts/ideas would be welcome.
Umbraco 9: custom 404 for missing static files
Hello
I am using a content finder (IContentLastChanceFinder) just fine for serving out a custom page for “Not found”/404 content requests. However, I am struggling to work out how to use a custom 404 page for static files (missing images etc).
I see that in the Umbraco core source code that the method RegisterDefaultRequiredMiddleware() https://github.com/umbraco/Umbraco-CMS/blob/v9/contrib/src/Umbraco.Web.Common/ApplicationBuilder/UmbracoApplicationBuilder.cs Umbraco registers “UseStatusCodePages” and “UseStaticFiles”, so to compliment that I thought a technique from https://bauchart.be/2017/10/01/custom-404-pages-in-asp-net-core-for-routes-and-static-files/ where my middleware replaces a 404 with my custom path (older page I know but the approach still sounds ok):
That didn’t work, so I tried the following with my custom path:
That didn’t work either. I'm not really sure if its because Umbraco core has already registered middleware and I can’t override/supersede that or that my registration sequence is incorrect (i did try things in different order), so any thoughts/ideas would be welcome.
I see that the donet site says its running .net 6 RC and a request for a static file results in a custom 404 https://dotnet.microsoft.com/missing.png
Thanks
Andrew
on https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-5.0, MS say this:
anyone have any thoughts? thanks
Hi Andrew, I'm facing the same challenge right now. Did you ever find a solution for this? Thanks!
is working on a reply...