BuildingACustomRouterForBlazor
BuildingACustomRouterForBlazor copied to clipboard
.NET 8+ - workaround without _Host.cshtml
In .NET 8+, the "web" mode of Blazor is preferred over "server". In this mode, I'm not aware of any instrumentation similar to MapFallbackToPage to redirect any request (sans static files as in this repository) to our own routing logic. The way it works in this mode seems unfriendly to letting us act via middleware:
var builder = WebApplication.CreateBuilder(args);
// services ..
var app = builder.Build();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
Similar projects like https://github.com/The127/FluentBlazorRouter use the same trick with MapFallbackToPage.
I, too, have built my own routing solution (https://github.com/lofcz/BlazingRouter), and I am looking for a way to bring this to the "web" model.
Would you happen to know whether some workaround is possible?