Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure invariant culture in ASP.NET globalization?

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

<configuration>    <system.web>       <globalization culture="???" />    ... 
like image 985
Mike Chaliy Avatar asked Jul 08 '09 19:07

Mike Chaliy


People also ask

How do you create an invariant 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.

What is globalization invariant mode?

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 .

What is invariant culture?

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.

How do I change the current culture in C#?

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.


1 Answers

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.

like image 114
Shravan Avatar answered Sep 28 '22 02:09

Shravan