0

I am coding a MVC 5 internet application that is being deployed to Azure. I am wanting to setup browser based culture so that DateTime values are displayed in the correct format for different cultures.

Here is my web.config code:

<globalization culture="auto:en-US" uiCulture="auto:en-US" enableClientBasedCulture="true"/>

Is this all that needs to be done? When viewing a view after the website has been published to Azure, only IE displays the DateTime in my current OS format. Both Google Chrome and Firefox are not using my current OS format.

Why is the DateTime value not being displayed in my current culture format (en-NZ)

Thanks in advance.

EDIT

I have removed the enableClientBasedCulture="true" from the web.config code, and the browser is still not displaying the DateTime values in my correct culture.

Simon
  • 7,991
  • 21
  • 83
  • 163

1 Answers1

0

From the documentation for the globalization Element (.NET 4), the attribute does nothing at the current time.

enableClientBasedCulture:

Optional attribute. This attribute is not in use at this time.

Community
  • 1
  • 1
  • How do you want them to display (dd/MM/yyyy)? And in a display format or in a textbox or in a datepicker? –  Mar 14 '15 at 07:09
  • The values are being displayed as simple text in a view. – Simon Mar 16 '15 at 02:21
  • If you set the culture to `` it will display as "dd/MM/yyyy". Or you can add the `[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}")]` attribute to the property. –  Mar 16 '15 at 02:39
  • I do know how to manually set the culture. So are you saying that currently it is impossible to use the browser to determine the culture? – Simon Mar 16 '15 at 08:24
  • Impossible to get it reliably. You can read the browser language using `Request.UserLanguages` but browsers are not required to send the `Accept-Languages` header so it can be null, or it can return multiple items (refer [these answers](http://stackoverflow.com/questions/8552927/what-is-q-0-5-in-accept-http-headers)). –  Mar 16 '15 at 09:00
  • I have seen solutions where the user selects a language when they register, so the value can be stored and retrieved for formatting purposes (e.g. in a custom `FormsAuthenticationTicket`). –  Mar 16 '15 at 09:04