I have a simple objective; I just want -every- single 404 error to redirect to a Single-Page Application for the SPA to handle routing.
This seems to work for routes that could possibly exist within the ASP.NET app (based on existing Controllers). However, if I navigate to a route that couldn't not possibly have been an ASP.NET route (which is happening, as some routes only exist client-side in the Vue app), it seems like IIS is immediately taking charge of the request and issuing this simple text/html response:
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
The response is issued almost immediately from receipt of the request, which seems to indicate it is being immediately handled as a 404 by IIS before any .NET managed handlers touch it.
How do I stop IIS from doing this?
Additional Info:
ASP.NET Web.config error fallback is already in place:
<system.webServer>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/vue-fallback.html" responseMode="File" />
</httpErrors>
</system.webServer>
This is an ASP.NET MVC Server; System.Web.Mvc v4.0.0.0.
IIS Version: IIS 8
ETA:
I ran the server locally (not sure why I didn't do this sooner), the exact error seems to be a failure in the StaticFile handler.
HTTP Error 404.0 - Not Found
...
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
This seems to solve my issue:
routes.MapRoute(
"Vue-Fallback",
"{*catchall}",
new { controller = "Home", action = "VueFallback" }
);
User contributions licensed under CC BY-SA 3.0