This is more specific and cleaner version of this question - Different DateTimeFormat for dev and test environment
In the Application_BeginRequest()
Well, I didn't actually find what IIS setting is responsible, but I've overridden it in Application_PreRequestHandlerExecute() and it finally worked:
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
Rather than setting the Thread's culture, you can specify it in the web.config like so:
<configuration>
<system.web>
<globalization uiCulture="en-GB" culture="en-GB" />
</system.web>
</configuration>
That is a more "proper" way of specifying the culture in ASP.NET.
To set a default Culture for your App in MVC, you can easily add this route in your RouteConfig class:
foreach (var route in routes.Cast<Route>().Where(route =>
route.GetType() == typeof(MultiLingualRoute)))
{
route.Url = "{language}/" + route.Url;
route.Defaults.Add("language", "YOUR-DEFAULT");
}
I think it is a good option to just let the client (i.e. user agent / browser) decide what culture he wants.
This can be done by setting the culture
and uiCulture
attribute of the globalization
element in web.config to auto
. See "Version 1".
You can also do something like: Take the broswers setting, but if not possbile use en-US
as fallback value. See "Version 2".
Version 1:
<configuration>
<system.web>
<globalization culture="auto" uiCulture="auto"/>
</system.web>
</configuration>
Version 2:
<configuration>
<system.web>
<globalization culture="auto:en-US" uiCulture="auto:en-US" />
</system.web>
</configuration>
See also this article for more info: Auto Detecting and Setting ASP.NET Locale based on Browser Locale