Tom
Tom

Reputation: 181

Route values are lost in the second pass of OnInitializedAsync() in Blazor Server

Problem:

In Blazor Server with render mode 'ServerPrerendered', I am observing that the route values are present in the first call of OnInitializedAsync().

enter image description here

However, the route values become empty after the framework calls OnInitializedAsync() the second time.

Question

My goal is to enable route based localization by getting language name from route (e.g. '//mypage'. As the routes are lost after the 2nd call, the language code cannot be obtained and the page fails to be localized.

Test Project in GitHub https://github.com/tsutomua/blazor/tree/main/BlazorLocalizationTest

Upvotes: 0

Views: 35

Answers (1)

Tom
Tom

Reputation: 181

Thanks @MrCakaShaunCurtis & @DavidThielen. Both solutions, use 1) PersistingComponentStateSubscription or 2) use MavigationManager) worked.

Upvotes: 0

Related Questions