BuildingACustomRouterForBlazor icon indicating copy to clipboard operation
BuildingACustomRouterForBlazor copied to clipboard

.NET 8+ - workaround without _Host.cshtml

Open lofcz opened this issue 10 months ago • 0 comments

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?

lofcz avatar Apr 10 '25 15:04 lofcz