-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Calling InvokeAsync(StateHasChanged) causes page to fallback to default culture #28521
Copy link
Copy link
Closed
Closed
Copy link
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-localizationquestionseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Metadata
Metadata
Assignees
Labels
✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Resolved because the question asked by the original author has been answered.Status: Resolvedaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-localizationquestionseverity-majorThis label is used by an internal toolThis label is used by an internal tool
Type
Fields
Give feedbackNo fields configured for issues without a type.
Describe the bug
In a Blazor Server application, I am updating page data from a background service. This update from the service ultimately ends up calling
InvokeAsync(StateHasChanged)in the page. The page is also usingIStringLocalizer<T>to provide translations for table headers. When the application runs, the user can select the current culture (e.g. German (de-DE)), and the table is displayed with translated headers. As soon as the background updates begin, the German culture is ignored, and the page is rendered using English (en-US) resources.My expectation is that calling
StateHasChangedwill use the proper resources for rendering the page.To Reproduce
I have created a small application that reproduces this scenario:
https://github.com/DaveNay/Service_Localization_Debugging
In the sample application, you can switch to the FetchData page, and then change the culture to German. You will see that the page is rendered with the de-DE resources. 10 seconds after the application starts, the background updates will begin. As soon as the updates begin, the page is rendered using en-US resources.
Exceptions (if any)
None
Further technical details