ASP.NET应用程序不反映区域设置 [英] ASP.NET application doesn't reflect Regional settings

查看:277
本文介绍了ASP.NET应用程序不反映区域设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置,在我的区域设置(捷克,文化CS-CZ),短时间/长时间模式下:

I've set, in my regional settings (for Czech, culture cs-CZ), the short time / long time pattern to following:

  • 短的时间:H.mm
  • 在很长一段时间:H.mm.ss

我想要使用C#应用程序的设置。 在下面的控制台应用程序,一切正常:

I'm trying to use those settings in C# applications. In following console app, everything works:

使用系统; 使用System.Globalization;

using System; using System.Globalization;

class Program
{
    static void Main()
    {

        Console.WriteLine(CultureInfo.CurrentCulture.Name);
        Console.WriteLine(CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern);

        Console.ReadLine();
    }
}

的输出,因为我认为,以下内容:

The output is, as I thought, following:

cs-CZ
H.mm.ss

我创建ASP.NET应用程序,它,我极处的惊喜,没有反映这一点。

I've created ASP.NET application, which, to my uttermost surprise, doesn't reflect this.

小例子:

<%@ Page Language="C#" %>

<%= System.Globalization.CultureInfo.CurrentCulture.Name %><br />
<%= System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern %>

输出:

cs-CZ
H:mm:ss

我试图重新启动,.NET2.0,.NET4.0,仍然没有效果。

I've tried restarting, .NET2.0, .NET4.0, still no effect.

请注意 - 这个问题提出的错误的一部分,我们忘了,包括InvariantCulture的的则DateTime.ToString(),它应该再由JSON解串器进行解析。 (这个问题的人有一些不同时间格式分隔符)。

Note - This issue raised as a part of bug, where we forgot to include InvariantCulture for DateTime.ToString(), which should then be parsed by JSON deserializer. (The guy with this problem has somewhat different Time format separator).

杀青问题,重新创建的CultureInfo是不是我要找的,我只是想看看的原因,因为我无法用任何手段重现该问题。

Fixing the issue with re-creating CultureInfo isn't something I'm looking for, I just want to see the reason, as I wasn't able to reproduce the issue with any means.

推荐答案

现在的问题是,该区域设置特定的用户。你改变了然后的的,但该网站作为不同用户运行(参见应用程序池在IIS)

The problem is that the Regional Settings are user specific. You changed then for you, but the site runs as a different user (see the app-pool in IIS)

这篇关于ASP.NET应用程序不反映区域设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆