Recently I noticed that my 404 page isn’t getting hit when routing to files that don’t exist.
For example (port is arbitrary here),
If I go to localhost:55311/mysite/a/a/a/a/a → I get taken to my 404 page.
But If I go to localhost:55311/mysite/a/a/a/a/a.png → I get taken to the browser’s generic not found page
So far, in order to remedy this, I’ve tried adding a httpErrors section to my XML, which didn’t work, as well as setting up a ContentLastChanceFilter to try and catch and handle these cases, but it does not get hit when routing to the url with an extension.
Rather confused how to go about setting this up, and any help is greatly appreciated!
The solution, I think, may be different depending on that.
One thing to note is that the static file handling process, triggered when there is a file extension I believe, (for both < v8 and v9>) happen outside of the Umbraco content routing which is why the custom 404 approach for content doesn’t work in these scenarios.
I do have a middleware being used for other things that does get hit when trying to route to file extensions (Both existing and tries to on non-existing). Though my assumption here is that Umbraco has some built-in way to handle this as opposed to needing to write another middleware to do so