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:
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.
If you simply set the culture for a running thread any operation that results in a thread switch (such as another part of the page lifecycle in asp.net) would result in reversion to the default culture.
The recommended approach is here ...
http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
This page discusses 3 options ...
It's worth noting that any modules are loaded as part of a page request so changing the culture at page level should change it for all modules on that request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With