简体   繁体   中英

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 (ie pl-PL) in a whole application?

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

  • 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" /> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM