'ASP.NET Core MapFallbackToFile is not handling non-existings urls. Only homepage
I am creating Blazor app. If I navigate to homepage - page loads fine, then I navigate into article e.g. localhost/new-article
. Next step is page refresh via F5. Page returns 404 not found. My fallback is not picking it up.
Startup.cs
endpoints.MapBlazorHub(blazorOptions =>
{
blazorOptions.ApplicationMaxBufferSize = blazorOptions.TransportMaxBufferSize = 20 * 1024 * 1024;
});
endpoints.MapRazorPages();
endpoints.MapControllers();
endpoints.MapFallbackToFile("/_Host");
Fallback should take localhost/new-article
however I dont know why its not.
_Host.cshtml first line
@page "/"
Solution 1:[1]
I believe the issue here is that you need to swap MapFallbackToFile to MapFallbackToPage.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | e36M3 |