调试自定义区域性问题

发布于 2024-08-06 06:40:20 字数 335 浏览 5 评论 0原文

在本地计算机上调试时,我遇到了自定义区域性问题。我有一个网站,该网站为内部用户和外部用户提供单独的 resx 文件(术语不同)。

我们使用自定义区域性 en-GB-external 和关联的 resx 来实现此目的。内部客户端将使用 en-GB resx 文件。

在一台PC上调试时,我只得到en-GB.resx文件,而不是en-GB-internal.resx文件。但是,如果我构建代码并将其放在服务器上,然后从同一台 PC 上进行浏览,它就可以工作。

如果我在另一台 PC 上调试相同的代码(从 svn 检出),它可以正常工作。

我可以从哪里开始确定为什么在一台 PC 上调试时不起作用?

I am having an issue with a custom culture when debugging on my local machine. I have a web site that has a separate resx file for internal vs external users (terminology is different)

We implement this using a custom culture en-GB-external and associated resx. Internal clients would use the en-GB resx file.

On one PC when debugging, I only get the en-GB.resx file, not the en-GB-internal.resx file. However if I build the code and drop it on a server, and browse from the same PC it works.

If I debug the same code (checked out from svn) on another PC it works fine.

Where can I even start looking to determine why this doesn't work when debugging on one PC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最单纯的乌龟 2024-08-13 06:40:20

也许检查 IE 的文化设置。

Check IE's culture settings perhaps.

静谧幽蓝 2024-08-13 06:40:20

我们遵循 msdn 实施自定义文化的示例。然而,我们会在页面生命周期的早期就切换文化。通过让不同的用户登录两个不同的页面解决了上述问题。然后我们重写InitializeCulture:

protected override void InitializeCulture()
    {
        SetCulture("en-GB-Internal");
        base.InitializeCulture();
    }
public void SetCulture(string nameOfCulture)
    {
        CreateCultureCookie(nameOfCulture);
        SetCurrentThreadCultureFromCultureCookie();
    }

    public void CreateCultureCookie(string name)
    {
        CultureInfo culture = new CultureInfo(name);

        HttpCookie cultureCookie = new HttpCookie("CultureCookie", culture.Name);
        cultureCookie.Expires = DateTime.Now.AddDays(30);

        AddCookie("CultureCookie", cultureCookie);
    }
private void SetCurrentThreadCultureFromCultureCookie()
    {
        if (Request.Cookies["CultureCookie"] != null && Request.Cookies["CultureCookie"].Value != null)
        {
            CultureInfo culture = new CultureInfo(Request.Cookies["CultureCookie"].Value);
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
        }
    }

We followed the msdn example of implementing custom cultures. However we then switch cultures as early in the page lifecycle as possible. The issue above was fixed by having the different users login on 2 different pages. We then override the InitializeCulture:

protected override void InitializeCulture()
    {
        SetCulture("en-GB-Internal");
        base.InitializeCulture();
    }
public void SetCulture(string nameOfCulture)
    {
        CreateCultureCookie(nameOfCulture);
        SetCurrentThreadCultureFromCultureCookie();
    }

    public void CreateCultureCookie(string name)
    {
        CultureInfo culture = new CultureInfo(name);

        HttpCookie cultureCookie = new HttpCookie("CultureCookie", culture.Name);
        cultureCookie.Expires = DateTime.Now.AddDays(30);

        AddCookie("CultureCookie", cultureCookie);
    }
private void SetCurrentThreadCultureFromCultureCookie()
    {
        if (Request.Cookies["CultureCookie"] != null && Request.Cookies["CultureCookie"].Value != null)
        {
            CultureInfo culture = new CultureInfo(Request.Cookies["CultureCookie"].Value);
            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文