I have just migrated around 100 ASP.net sites from IIS 6 on Windows Sever 2003 to IIS 7 on Windows 2008. I've just noticed that various pieces of code that use things like DateTime.Parse have started kicking up errors "String was not recognized as a valid DateTime". I've tracked this down to the fact that the CurrentCulture of the sites is defaulting to 'en-US' and so my UK users are inputting dates in an unexpected format.
Question is, where are they getting en-US from? Starting from the top, if I look in 'Control Panel > Region and Language' everything is set to English (United Kingdom). The web.configs of the sites either don't have a <globalization> section or have it set as <globalization culture="auto" uiCulture="auto" />. In 'IIS7 - .Net Globalization' all of the sites have their culture set to 'Invariant Language (Invariant Country)'.
I can't find anywhere that's settings the culture to 'en-US'... but something is.
Thread.CurrentThread.CurrentCulture.Name is outputting 'en-US'
Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol is outputting '$'
I can fix the issue by adding <globalization culture="en-GB" uiCulture="en-GB" /> to every web.config BUT I really don't want to have to hand edit about 100 web.configs! I wan't it to inherit the culture from the server OS settings, which are set to en-GB.
Am I missing something?
CurrentUICulture
is always en-US for any version of English thatCurrentCulture
is set to. So, it may be that the curreny culture is being set from the UI Culture. Did you try what happens when you set a non-English language, especially a language with variants that display things like dates differently? – Trencherman