Different DateTimeFormat for the same culture in different machines

后端 未结 3 951
面向向阳花
面向向阳花 2021-01-19 06:32

I\'m having a problem when I deploy my web application in different servers. There seems to be an inconsistency in some DateTimeFormat patterns, like Shor

3条回答
  •  没有蜡笔的小新
    2021-01-19 07:05

    Actually, I was trying to use the code above in the wrong place in the Global.asax file.

    I managed to override the ShortDatePattern for the entire aplication by putting the code in the Application_BeginRequest method:

    protected void Application_BeginRequest()
    {
        CultureInfo info = new CultureInfo(System.Threading.Thread.CurrentThread.CurrentCulture.ToString());
        info.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
        System.Threading.Thread.CurrentThread.CurrentCulture = info;
    }
    

提交回复
热议问题