I’m considering the use of the ‘globalization’ web.config section in our ASP .NET application to provide a default culture to be applied to all requests. In some cases, we’ll be overriding this value programmaticly during the ‘AcquireRequestState’ event, but I’d like to know at what stage in the request life cycle the ‘culture’ and ‘uiCulture’ properties of the ‘globalization’ section will be applied to the thread servicing the request.
I’m assuming that there’s some code in the System.Web namespace that looks like this:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(webConfigCulture);
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(webConfigUiCulture);
Where ‘webConfigCulture’ and ‘webConfigUiCulture’ represent the values of the ‘culture’ and ‘uiCulture’ in the globalization section of the web.config.
Anyone know where this is happening (e.g. what request/page event)? Or am I way off base?
Altually, the culture is stored in the http context rather than the thread, and copied from there to the thread. A request can be moved from one thread to another over the page cycle, so the culture has to follow the request, not the thread.
So, the culture is applied when the http context object is created, which happens at “Start” stage of the page cycle, before the
PreInitevent.You can read more here: ASP.NET Page Life Cycle Overview