1

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?

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
cpoDesign
  • 8,953
  • 13
  • 62
  • 106

1 Answers1

3

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...

Remy
  • 12,555
  • 14
  • 64
  • 104
  • I have used same solution. The issue is while is the page reloading many times along the way the thread culture is reset to default. – cpoDesign Oct 25 '12 at 14:10
  • This is being called on every request. Also on reloads. There must be something else in your app that resets it. When does tit exactly happen? – Remy Oct 25 '12 at 15:16
  • When my app hits global.asax I do set my culture. After when it starts rendering default page in page_load event I do set the culture of the page again but while it is reloading couple times it seems loose the settings – cpoDesign Oct 26 '12 at 10:35
  • There is no need to set the culture again. I would try to debug and figure out when exactly your culture changes. – Remy Oct 26 '12 at 13:28