Reputation: 181
Problem:
In Blazor Server with render mode 'ServerPrerendered', I am observing that the route values are present in the first call of OnInitializedAsync().
However, the route values become empty after the framework calls OnInitializedAsync() the second time.
Question
Server
' render mode rather than 'ServerPrerendered
'. It resulted in calling the OnInitializedAsync()
only once, but route values are empty.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
Reputation: 181
Thanks @MrCakaShaunCurtis & @DavidThielen. Both solutions, use 1) PersistingComponentStateSubscription or 2) use MavigationManager) worked.
Upvotes: 0