I need to fix CurrentCulture as the invariant culture in an ASP.NET application. How can I do this?
<configuration> <system.web> <globalization culture="???" /> ...
You specify the invariant culture by name by using an empty string ("") in the call to a CultureInfo instantiation method. CultureInfo. InvariantCulture also retrieves an instance of the invariant culture. It can be used in almost any method in the System.
Invariant modeDetermines whether a . NET Core app runs in globalization-invariant mode without access to culture-specific data and behavior. If you omit this setting, the app runs with access to cultural data. This is equivalent to setting the value to false .
The invariant culture is a special culture which is useful because it will not change. The current culture can change from one user to another, or even from one run to another, so you can't rely on it staying the same.
CurrentCulture = New CultureInfo("th-TH", False) Console. WriteLine("CurrentCulture is now {0}.", CultureInfo.CurrentCulture.Name) ' Display the name of the current UI culture. Console. WriteLine("CurrentUICulture is {0}.", CultureInfo.CurrentUICulture.Name) ' Change the current UI culture to ja-JP.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With