Why Does Thread.CurrentThread.CurrentCulture Change between Page Rendering and HttpModule.PostReques
Posted
by Chad
on Stack Overflow
See other posts from Stack Overflow
or by Chad
Published on 2010-02-24T20:37:09Z
Indexed on
2010/05/20
10:30 UTC
Read the original article
Hit count: 418
I'm creating an HttpModule that needs to know the value of Thread.CurrentThread.CurrentCulture as set in an MVC application. That value is currently being set by the BaseController, but when my HttpModule.PostRequestHandlerExecute() method fires, it reverts to what the Culture was prior to page rendering.
I have duplicated this by creating a simple web app with these steps:
- Module.PreRequestHandlerExecute: Set culture to A
- Page_Load: Culture is currently A. Set culture to B
- Module.PostRequestHandlerExecute: Current thread culture is A. I expected it to be B but it was changed between page rendering and PostRequestHandlerExecute
Any idea why .Net changes this value or how I could get around it? The thread is the same, so something in .Net must be explicitly reverting the culture.
© Stack Overflow or respective owner