Setting up Culture to Aspx website

时光毁灭记忆、已成空白 提交于 2020-01-05 10:33:08

问题


I have website that has some issue to work with. One of the issues is loading 5x.

I have been trying to set language speficic for the page. My problem is as follows:

While page is refreshing n times it does somewhere overrides page language settings. I had as test modified global.asax page in Application_Start method. This method gets called only once. After this page goes into default.aspx page and hits the page ntimes, when the page gets initialised it change culture to default culture en-GB instead to the one I have set in Page_Load event.

I have set the thread . current . UI and Culture to my specific culture. But this does't work.

I have tried:

  1. Set language in global.asax
  2. Set language in global.asax + onload page for my default.aspx
  3. Use session to set language and after reload the page to display in correct page.

Any ideas?


回答1:


If you add this to Global.asax.cs it should work. It works for me.

protected void Application_BeginRequest(object sender, EventArgs e)
{
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-ch");
    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("de-ch");
}

But your description of the issue is a bit confusing...



来源:https://stackoverflow.com/questions/13054270/setting-up-culture-to-aspx-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!