4

I am running a site on IIS that reads the culture info from Thread.CurrentThread.CurrentCulture. This comes from the System culture info from what I understand. I need it set to a certain value and I've been unable to change it at the OS level.

My windows 7 computer was initially set up in the en-GB culture, and I now need to switch it to en-US. I have changed it in the Region and Language control panel. In the Formats tab, The Format is English (United States), In the Location tab, the current location is United States, in the Administrative tab, Current language for non-Unicode programs is English (United States). After restart, the values all read correct in the windows UI.

I've restarted my computer after those changes, I've cleared my local DNS (don't know if that matters), I've restarted IIS, I've recycled the app pool, but it still reads as en-GB.

Is there anything else I need to do to update this cultureInfo?

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
topher-j
  • 2,221
  • 5
  • 24
  • 35
  • 1
    Google "asp.net default culture". First hit looks good. – Hans Passant Oct 20 '12 at 00:46
  • The last comment on that thread was what I was looking for, thanks! I changed the .NET Globalization settings and it gave me what I wanted. It used to be set as Invariant Language, and I changed it to en-US – topher-j Oct 21 '12 at 21:00

1 Answers1

5

ASP.NET itslef has configuration for that task. Culture could be set (many ways) inside a web.config file in the system.web section. The below snippet shows, how could be en-US culture forced

<globalization 
    enableClientBasedCulture="false" 
    uiCulture="en-US" 
    culture="en-US" />

If application is ready to accept the culture from the client (browser), settings should be

<globalization 
    enableClientBasedCulture="true" 
    uiCulture="auto" 
    culture="auto" />

The above setting will take a Language selected in client browser (e.g. cs-CZ in my case). If none is defined then system settings will be used. Final snippet shows, how to allow client to set and send intended culture, but in case that no Language is pre-selected, override the system setting with some other default value en-US

<globalization 
    enableClientBasedCulture="true" 
    uiCulture="auto:en-US" 
    culture="auto:en-US" />
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • Thanks for the info, I needed to change it at the server / OS level though, not through the application. – topher-j Oct 21 '12 at 21:01
  • Hmm, seems like I spoke too soon. Making the change to IIS changed web.config, and added . So something on my machine is still set to en-GB. – topher-j Oct 22 '12 at 05:04
  • If you need to change OS settings, then yes - it is different approach then my snippets. But in case, that your globalization will be set to allow client based culture, then those settings (from OS) will be overriden in a run-time. Just wanted to explain how could happen, that your OS is en-US, and "strange" en-GB is set to thread. (because browser language is en-GB) – Radim Köhler Oct 22 '12 at 05:13