Microsoft-identity-web: [Bug] null ref on NavigationManager on Blazor server w/AzureSignalR when using Prerendering

Created on 12 Aug 2020  路  4Comments  路  Source: AzureAD/microsoft-identity-web

Blazor server does prerendering to load the application initially, as noted in _Host.cshml:

<app>
        <component type="typeof(App)" render-mode="ServerPrerendered" />
</app>

This causes the NavigationManager to be null because the Blazor component is not yet started, as it is in "pre-rendering mode". Once the app is active, it renders again. On the pre-render, the MicrosoftIdentityCircuitHandler is not started.

Use the _httpContext in the case of the pre-render, as it is available at that time.

Customers can also choose to not pre-render, if they want.

<app>
        <component type="typeof(App)" render-mode="Server" />
</app>
Blazor P1 fixed

Most helpful comment

This has been fixed in master, but there are API breaking changes there, we do not have our documentation updated yet, but there is a migration aid, it might be a bit premature, but you are welcome to try this out, and/or the workaround of removing the prerendering (see above).
@DanielMannInCycle @schmid37 @gwgrubbs @jaimunday @josheinstein

All 4 comments

This has been fixed in master, but there are API breaking changes there, we do not have our documentation updated yet, but there is a migration aid, it might be a bit premature, but you are welcome to try this out, and/or the workaround of removing the prerendering (see above).
@DanielMannInCycle @schmid37 @gwgrubbs @jaimunday @josheinstein

Hey @jennyf19 the workaround works fine. I hope I'll find some time to test the master. Got some internal development I need to deliver in the next days.

Thanks for the quick feedback @schmid37 If there is anything we can do to help with the testing let us know.

Included in 0.3.0-preview release.

Was this page helpful?
0 / 5 - 0 ratings