2

The InitializeCulture() method can be overridden and you can easily choose your own Page.Culture and Page.UICulture. You can also add a globalization section in the Web.config or set the culture in your BasePage. But how are the default values of these properties determined and set exactly? Is the UICulture taken from the browser request's accept-header? is the Culture taken from the server?

Note that I'm not asking for the difference between these two properties, but where or when the default values are set if I don't set it anywhere in my application. So which browser-, user-, server-, ...settings outside of my application influence the value?

Community
  • 1
  • 1
Thomas Mulder
  • 740
  • 10
  • 26
  • Do you mean: IIS Manager -> Select your web site -> Select ".NET Globalization" settings, select Culture and UI Culture. – Matthew Watson Feb 08 '17 at 14:00
  • If that's the only thing that's taken into consideration, then yes, that's what I'm looking for. But if other things like the user's browser settings are taken into account as well I would love to hear about which setting trumps which setting etc. – Thomas Mulder Feb 08 '17 at 14:09
  • In your link to Page.Culture it says beneath Remarks: "You can also set the value to auto which will perform automatic detection of the browser's preferred language and set it" – Magnus Feb 08 '17 at 14:11

1 Answers1

1

UICulture is a shortcut for Page.CurrentThread.CurrentUICulture, which is, according to docs:

The UI culture specifies the resources an application needs to support user input and output, and by default is the same as the operating system culture.

As for Culture, it is again a property of a running thread, but default here is determined in a more complicated way explained here. A short summary:

  1. Check DefaultThreadCurrentCulture property in the application domain
  2. If we are in .Net 4.6 or later and current thread is a task called by other thread, try get culture of the caller
  3. By calling the Windows GetUserDefaultLocaleName function (so OS again)
Andrei
  • 55,890
  • 9
  • 87
  • 108