Skip to content

CultureInfo.CurrentCulture not being preserved across Threads on Linux #5493

@ryanbrandenburg

Description

@ryanbrandenburg

MVC seems to have encountered a problem whereby the CurrentUICulture is not preserved across threads on Linux (windows works fine). If you run this project on windows, go to /Home/Index and request "fr" as your language all the fields should display french data. However, if you run it on Linux AND the Controller and View execute on different threads then you will get English as the CurrentUICulture of the View because it's not preserved across the thread switch and English is the default.

Here's a screenshot of what it looks like when this happens:
threadculture

Basically we set the CurrentUICulture of the thread based on your request (query-string, header or cookie), the Controller receives that Culture without trouble, we do something async, then create our View. The view doesn't have the same culture as the Controller by the time it executes.

Also of note is that if you keep trying this you will stop getting the English results because it becomes more and more likely that the View thread will be "pre-populated" with french from when it previously hosted the Controller.

CC @rynowak and @javiercn to make sure I explained it fully and understandably.

Metadata

Metadata

Assignees

Labels

blockingMarks issues that we want to fast track in order to unblock other important work

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions