3

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 ?

BrilBroeder
  • 1,409
  • 3
  • 18
  • 37
  • `When adding a MapFallBackToFile suddenly some Api-Endpoint do not get hit anymore` Please share the code of those corresponding API action(s) and the relevant code you are using to make request to that API endpoint from blazor-webassembly front-end, so that we can help troubleshoot the issue better. – Fei Han Mar 03 '21 at 05:45
  • I'll try to strip the project down to the basics and share it. – BrilBroeder Mar 08 '21 at 08:27
  • I have a similar issue; I believe that endpoints do not follow any priority logic, so the fallback may be called or not based on pure randomness, as long as it's not mapped to a file (I'm not sure but that's my conclusion up to now). I think MapFallbackToFile might just not be reliable with Api controllers. Did you find a solution? – Christian Rondeau Jun 01 '21 at 17:21
  • Does this answer your question? [How to map fallback in ASP .NET Core Web API so that Blazor WASM app only intercepts requests that are not to the API](https://stackoverflow.com/questions/61268117/how-to-map-fallback-in-asp-net-core-web-api-so-that-blazor-wasm-app-only-interc) – Christian Rondeau Jun 01 '21 at 17:27
  • This nearly killed me. My api calls were redirecting to the spa home page, maksing and underlying error (db connection). The solution was to comment out MapFallback() and put in the detailed error page, fix my error, then reactivate MapFallback(). – bbsimonbb Sep 16 '22 at 16:17

0 Answers0