Searching the web, I am seeing plenty of instances where the following combination of attributes is used in the globalization section: culture="auto", uiCulture="auto", enableClientBasedCulture="true", e.g.:
<globalization uiCulture="auto" culture="auto" requestEncoding="utf-8" responseEncoding="utf-8" enableClientBasedCulture="true"/>
The documentation says: http://msdn.microsoft.com/en-us/library/system.web.configuration.globalizationsection.enableclientbasedculture(v=VS.90).aspx
When the EnableClientBasedCulture property is enabled, the Culture and UICulture properties are based on the AcceptLanguage header field value that is sent by the client browser. If the AcceptLanguage header value cannot be mapped to a specific culture, the Culture and UICulture values are used. The default value is false.
For the culture and uiCulture attributes, "auto" is supposed to mean http://msdn.microsoft.com/en-us/library/bz9tc508(v=VS.90).aspx
To have ASP.NET set the UI culture and culture to the first language that is specified in the current browser settings, set UICulture and Culture to auto. Alternatively, you can set this value to auto:culture_info_name, where culture_info_name is a culture name. For a list of culture names, see CultureInfo. You can make this setting either in the @ Page directive or Web.config file.
Suppose the browser sends an invalid or no culture name in the AcceptLanguage header field value. Because enableClientBasedCulture="true", the application server is supposed to attempt to use whatever is in the AcceptLanguage header field, but with an invalid culture name, it fails to do so and falls back on culture="auto" and uiCulture="auto", but the auto/auto settings themselves will fail to make any use of the invalid data.
Now suppose we do send the server a valid culture name, e.g. "de-DE". The application server is still told to make use of the AcceptLanguage header field value because enableClientBasedCulture="true", but since culture and uiCulture are set to "auto", they would have made use of that value anyway.
My first question is: What is the point in combining auto/auto with true? My own belief is that if culture="auto" and uiCulture="auto", using enableClientBasedCulture="true" would be redundant. My own tests have shown that auto/auto works just as well alone as they do when combined with the enableClientBasedCulture attribute, but as I am seeing the auto/auto/true combination being suggested in many examples on the web, I am wondering if I have overlooked something.
I have tried using enableClientBasedCulture="true" without the auto/auto settings, e.g.
<globalization requestEncoding="utf-8" responseEncoding="utf-8" enableClientBasedCulture="true"/>
This does not seem to work at all; it appears that the client is force-fed the server's culture and uiCulture settings, even though enableClientBasedCulture="true" is supposed to (implicitly?) take care of setting those properties to that of the AcceptLanguage header field value.
I then tried combining enableClientBasedCulture with a specific culture for culture and uiCulture, e.g.
<globalization uiCulture="da-DK" culture="da-DK" requestEncoding="utf-8" responseEncoding="utf-8" enableClientBasedCulture="true"/>
In this case, the client browser was forced to use "da-DK", regardless of its language settings.
Looking at http://msdn.microsoft.com/en-us/library/hy4kkhe0(v=VS.90).aspx I see this for enableClientBasedCulture:
This attribute is not in use at this time.
Using .NET Reflector, I have decompiled all of the .NET 3.5 Framework assemblies and searched for enabledClientBasedCulture. I have found some code in System.Web.Configuration\GlobalizationSection that reads the value and makes it available through a property, but otherwise does nothing with it.
In Hosting\HostingEnvironment I find a method named SetCultures which grabs the culture and uiCulture values from a GlobalizationSection parameter, but I have yet to find any code that makes use of the enableClientBasedCulture attribute.
So my second question is: Is the enableClientBasedCulture attribute actually being used anywhere at all and if so, how should I configure a test program in order to prove to myself that it has any effect?
When the EnableClientBasedCulture property is enabled, the Culture and UICulture properties are based on the AcceptLanguage header field value that is sent by the client browser. If the AcceptLanguage header value cannot be mapped to a specific culture, the Culture and UICulture values are used.
MSDN says that enableClientBasedCulture
is not used.
"enableClientBasedCulture - Optional attribute. This attribute is not in use at this time."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With