Setting User language for Localization/Globalization
I need to select the language based on the user choice and set it for the entire session. Can anybody suggest 开发者_JS百科where do i need to do these settings and how can i do this?
See CultureInfo.
A tutorial can be found here . Briefly: change Thread.CurrentThread.CurrentUICulture
and Thread.CurrentThread.CurrentCulture
I got the solution by setting the current thread in global.asax
protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
if (HttpContext.Current.Session != null)
{
if (HttpContext.Current.Session["userCultureInfo"] != null)
{
Thread.CurrentThread.CurrentUICulture = new CultureInfo(Session["userCultureInfo"].ToString());
}
}
}
精彩评论