Łukasz Bańcarz
Łukasz Bańcarz

Reputation: 125

ASP.NET MVC4 Deployed on Azure localization

I've created an application in ASP.NET MVC4. Everything is ok on my Visual Studio 2012 IIS Server. The problem is when i publish it on Azure, then when i call DateTime.Now i got time from other time zone than mine and also when i want to display date : DateTime.Now.ToString("dd MMMM yyyy") month name is in english. How can I specific culture (i.e. pl-PL) in a whole application?

I've tried <Globalization Culture="pl-PL" UICulture="pl-PL" /> in web.config but with no effect

Upvotes: 1

Views: 1759

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241728

  • Azure runs all servers in UTC, which is appropriate.
  • You should never call DateTime.Now in a server application. That imposes the time zone of the server into the results. There is no good reason for that - you should be able to deploy your application anywhere. Read more here.
  • Culture will only affect formatting, not time zones. And only the Culture setting affects the output of DateTime.ToString(). The UICulture doesn't matter (for this regard).
  • It's not picking up your values from web.config because it is case sensitive and you are using the incorrect casing. Reference here. You need:

    <globalization culture="pl-PL" uiCulture="pl-PL" />
    

Upvotes: 3

Related Questions