Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to set Locale setting in a c# web application globally

To be able to set your web application global setting, you need to set it in global.asax file. And to make it more dynamic it's better to set the locale setting string in web.config.

//web.config
<configuration>
  <appSettings>
  <add key="Locale" value="en-PH" />
  </appSettings>
<configuration>

//global.asax
public void Application_BeginRequest(object sender, EventArgs e)
{
  Thread.CurrentThread.CurrentCulture = new CultureInfo(ConfigurationManager.AppSettings["Locale"]);
  Thread.CurrentThread.CurrentUICulture = new CultureInfo(ConfigurationManager.AppSettings["Locale"]);
}
How to set Locale setting in a c# web application globally How to set Locale setting in a c# web application globally Reviewed by Edward Legaspi on Monday, July 04, 2011 Rating: 5

No comments:

Powered by Blogger.