endpoints.MapFallbackToFile("index.html") messes up routing in asp.net core project

Viewed 2452

The solution has a web-api project that is also the host for a blazor-webassembly front-end.

With this config all works fine. WebApi endpoint get hit correctly when called from postman.

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
        endpoints.MapRazorPages();
    });

When adding a MapFallBackToFile suddenly some Api-Endpoint do not get hit anymore but serve that default file.

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllers();
            endpoints.MapRazorPages();
            endpoints.MapFallbackToFile("index.html");
        });

The reason for adding this fallback : serve as landing page for the Blazor front-end.

Any suggestions ?

0 Answers
Related