Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

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

$
0
0

Problem:

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

enter image description here

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

Question

  • Is there a way to get the route values after the second call? I tried the '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 GitHubhttps://github.com/tsutomua/blazor/tree/main/LocalizationTestApp.


Viewing all articles
Browse latest Browse all 4839

Trending Articles