开发者

Changing the user language in an asp.net application based on user choice

I have web application which supports globalization. So i need to provide user a choice to select a language one he/she logs in. Now the problem i开发者_如何学编程s where do i have to make changes to set the user's preferred language.


Use the ASP.NET profile feature to declare the user's preferred language as a profile property. See Tutoriel

(Note that this is a rephrasing of @Ikaso's answer, so s/he should answer and get credits)


Ok I got the solution: I tried the following changes in the global.asax file

protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{           
 if (Session["userCultureInfo"] != null)
  {             
   Thread.CurrentThread.CurrentUICulture = new CultureInfo(Session["userCultureInfo"].ToString());
   }           
}


Alternatively to the solution you got, you can have your own HTTP module and set the culture there by passing it through the URL for example. But you need to do that in the module before the page lifecycle starts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜