Alex Rivera | Logout

Do we affect multiple users in ASP.NET when we set the Thread CurrentCulture/CurentUICulture?

Asked 2010-05-19T07:30:38.847
10

When we set the CurrentCulture and/or CurrentUICulture we do this on the current thread like this:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");

Doest this mean we could affect the culture settings of multiple users of our web application as their requests may reuse the threads from pool?

I am working on an ASP.NET MVC application where each user may have own culture setting specified in his/her account data. When the user logs in, the culture setting is retrieved from the database and has to be set as current culture.

My worry is that setting the current culture on the current thread may affect another user request reusing this thread. I am even more concerned reading this:

ASP.NET not only uses a thread pool, but may switch threads during request processing.

Edit
Report

1 Answer

0

In standard ASP.NET I used the Page fields UICulture and Culture. Thread contexts are then changed as different parts of the request are executed on the thread.

In saying that I'm not familiar with how MVC manages it, but I'd reckon that it should be applied in the view, and given that views are viewpages which inherit from page, they'll have UICulture and Culture as per ASP.NET standard...

In saying all that, dont take this as gospel, as I say, I haven't done much with ASP MVC...

answered 2010-05-24T16:16:25.177

Your Answer