How do I change the language of an application in ASP.NET?

I am developing an application with ASP.NET 3.5 and I read that the language the application is shown in is the navigator language.

Is there any way to programmatically select the application language? For example, I want to see an application in English, but my Internet Explorer is in Spanish.

Language is a custom setting saved in the database, so I need to change the language when the user logs in.

0


a source to share


4 answers


You can use the CultureInfo class to set the culture for your runtime.



CultureInfo ci = new CultureInfo("en-US", false);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

      

+3


a source


Are you asking how to change your browser, accept the language? See http://windowshelp.microsoft.com/Windows/en-US/help/7b4a0825-28e2-4929-82f6-1feac4adb6f31033.mspx for instructions for IE 7 and IE 8. The section you want is the Add Language in Internet Explorer "



0


a source


You can also set it in web.config:

<configuration>
 <system.web>
  <globalization
    requestencoding="utf-8"
    responseencoding=" utf-8"
    fileencoding=" utf-8"
    culture="en-US"
    uiculture="en-US" />
 </system.web>
</configuration>

      

Or at the page level:

<%@ Page Culture="en-US" UICulture="en-US" ResponseEncoding="utf-8"%>

      

0


a source


You can use this one <globalization culture="en-US" uiCulture="en-US"/>

in your <system.web>

web.config section.

0


a source







All Articles