How to configure invariant culture in ASP.NET globalization?

后端 未结 2 866
花落未央
花落未央 2020-11-29 06:32

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


   
      

        
相关标签:
2条回答
  • 2020-11-29 06:54

    Either add the following to your web.config file:

    <system.web>
        <globalization culture="en-US" uiCulture="en-US" />
    </system.web>
    

    or you can add this statement on the page:

    <%@ Page uiCulture="en-US" culture="en-US" %>
    

    Hope this helps.

    0 讨论(0)
  • 2020-11-29 06:55

    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"
    
    0 讨论(0)
提交回复
热议问题