问题
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
回答1:
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://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-3.0
来源:https://stackoverflow.com/questions/58118874/child-blazor-app-on-blazor-server-side-app