Reputation: 115
Adding a Client side Blazor app to a Server Side Blazor app
Hi
Following on to the helpful answer here
Blazor sub app 404 error after upgrade to Preview 6
I have run into a situation where it would be helpful to be able to add a Client side Blazor app to a Blazor server side app
I have created the Blazor Server app, attached a client app the the server app, and adjusted the server startup.cs to map the child app. I have also confirmed the client apps index.html base value is correct
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
app.Map("/subapp", child =>
{
child.UseRouting();
child.UseEndpoints(endpoints =>
{
endpoints.MapFallbackToClientSideBlazor<BlazorCoreHosted.Subapp.Startup>("index.html");
});
child.UseClientSideBlazorFiles<BlazorCoreHosted.Subapp.Startup>();
});
When I go to the localhost/subapp page the parent app shows "Sorry, there's nothing at this address.", and I can see the parent app is intercepting the routing
Is there a way to get around this, or is this not a valid scenario?
Thanks
Mark
Upvotes: 3
Views: 1096
Reputation: 115
Thanks to the suggestion from 'agua from mars', and reading the link below I experimented with changing the order of where I use app.map
Moving app.map to before app.UseRouting(); creates the expected result
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-3.0
Upvotes: 2