CurrentCulture incorrectly defaulting to en-US in ASP.net

后端 未结 9 1253
执笔经年
执笔经年 2020-12-08 14:37

I have just migrated around 100 ASP.net sites from IIS 6 on Windows Sever 2003 to IIS 7 on Windows 2008. I\'ve just noticed that various pieces of code that use things like

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 15:03

    Just to help someone gets the same problem....

    After tried change IIS Culture, set globalization and so far unsecessfully, i did it in Global.asax:

    void Application_BeginRequest(Object sender, EventArgs e)
    {
        System.Globalization.CultureInfo newCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
    
        newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
        newCulture.DateTimeFormat.DateSeparator = "/";
    
        System.Threading.Thread.CurrentThread.CurrentCulture = newCulture;
    } 
    

提交回复
热议问题