I am developing three web applications that are part of a larger system. These are single page applications with an API, and as such I have wildcard route for non API actions that points to my main controller.
For two of these applications this works fine but for the third the redirect doesn't work and I just get a 404 returned when trying to access a front end route. The setup as far as I can tell is identical and I am completely stumped as to why it is not working.
I am using screenshots rather than code snippets so I can show the setup side by side (working on the left, not working on the right).
As you can see the key sections of code are identical in both applications and yet one works and one doesn't.
What have I missed? Where else should I look? And any guidance on how I can debug this would be greatly appreciated.
This is the key bit of code which as you can see is identical in both places:
app.UseMvc(routes =>
{
routes.EnableDependencyInjection();
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
app.MapWhen(x => !x.Request.Path.Value.StartsWith("/api", StringComparison.OrdinalIgnoreCase), builder =>
{
builder.UseMvc(routes =>
{
routes.MapRoute("spa-fallback", "{*url}", new { controller = "Home", action = "Index" });
});
});



