Closed
Description
It looks like Blazor Server is using relative paths in a couple of places that limit when it can be used. This caused some issues when I tried to use Blazor components in an MVC app on any view other than the home page.
Repro steps:
- Create an MVC app
- Add
services.AddServerSideBlazor()
toStartup.ConfigureServices
andendpoints.MapBlazorHub()
inStartup.Configure
. - Add the blazor.server.js script to the layout using the script tag we use in the Blazor Server template:
<script src="_framework/blazor.server.js"></script>
- Add a Razor component to the project with some sort of user interactivity support.
- Add the component to the Privacy.cshtml page:
@(await Html.RenderComponentAsync<MyComponent>(RenderMode.ServerPrerendered))
- Run the app and browser to the Privacy page
Actual result:
- The component is not interactive, because the request for blazor.server.js goes to /Home/_framework/blazor.server.js.
- To work around this issue, update the script tag to use
~/
:<script src="~/_framework/blazor.server.js"></script>
. Should we do this everywhere? - The component is still not interactive because the SignalR client tries to connect to
/Home/_blazor/
. This seems like a bug we need to fix in blazor.server.js?