ThinkGeo.com    |     Documentation    |     Premium Support

How to change globalization settings in ASP.NET MVC 6?

Before, I host at asphostportal.com, I can setup globalization settings in the web.config in order to change the UICulture to en-US.  For example:


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


How can I do the same things in ASP.NET 5 (ASP.NET MVC 6) equivalently?

Hi Florence,



I guess the change of web.config you did is correct, but sorry that I don’t know why it doesn’t work on your end. Please try changing the Culture and UICulture manually in the Global.ascx, the code looks like as following(It supports both ASP.NET 5 and ASP.NET MVC 6.0):


protected void Application_Start(object sender, EventArgs e)
 {
     CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(“en-US”);
     CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(“en-US”);
 }

For Asp.NET application, please try another option:


protected override void InitializeCulture()
  {
      Thread.CurrentThread.CurrentCulture = new CultureInfo(“en-US”);
      Thread.CurrentThread.CurrentUICulture = new CultureInfo(“en-US”);
      base.InitializeCulture();
  }

Thanks,

Johnny