如何配置不变的文化全球化ASP.NET? [英] How to configure invariant culture in ASP.NET globalization?

查看:118
本文介绍了如何配置不变的文化全球化ASP.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要修复的CurrentCulture在ASP.NET应用程序不变的文化。我怎样才能做到这一点?

 <结构>
   <&的System.Web GT;
      <全球化文化=??? />
   ...


解决方案

按照<一个href=\"http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28VS.71%29.aspx\">CultureInfo类文档,一个空字符串指定InvariantCulture的。

编辑(在.NET 3.5 SP1测试)

默认情况下,Culture和UICulture在web.config中设置为。我猜的.Net只是做自己的事,虽然,并将它们设置为en-US在运行时,即使文档中说,en是不变的文化,而不是EN-US。

@Page指令可以与你的干扰。如果您使用了页面设计的生成本地资源的工具,它会自动添加的文化=自动的UICulture =自动的到你的页面指令,它覆盖web.config中。如果你只是删除这些,有人使用该工具后,whammo,他们回来,设置为auto,窃听了您的应用程序。如果尝试将其设置为,你会得到一个错误。

精益求精同时设置web.config文件和页面指令来此与希望?

 文化=EN-US的UICulture =EN

I need to fix CurrentCulture as the invariant culture in an ASP.NET application. How can I do this?

<configuration>
   <system.web>
      <globalization culture="???" />
   ...

解决方案

According to the CultureInfo class documentation, an empty string specifies InvariantCulture.

Edit (tested on .NET 3.5 sp1)
By default, Culture and UICulture are set to "" in the web.config. I guess .Net just does its own thing though, and sets them to "en-US" at run time, even though the documentation says that "en" is the invariant culture, not "en-US".

The @Page directive could be interfering with you. If you used the "Generate Local Resources" tool of the page designer, it automatically adds culture="auto" uiculture="auto" to your page directive, which overrides the web.config. If you just delete those and someone uses that tool later, whammo, they come back, set to auto, bugging up your application. If you try to set them to "", you get an error.

Try setting both the web.config and page directive to this and hope for the best?

culture="en-US" uiculture="en"

这篇关于如何配置不变的文化全球化ASP.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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