title: Switching language on ASP.NET app using master page
body: <p>I am using Visual Studio 2008 and ASP.NET to build a web app. Most of my web pages are based on a single master page. This master page contains three button links that act as language switches; the <code>Click</code> event handlers look like this:</p>
  
  <pre><code>protected void lbuLangEN_Click(object sender, EventArgs e)
  {
      this.SwitchLanguage(string.Empty);
  }  
  
  protected void lbuLangES_Click(object sender, EventArgs e)
  {
      this.SwitchLanguage("es");
  }
  </code></pre>
  
  <p>Then I have my private method <code>SwitchLanguage</code>:</p>
  
  <pre><code>private void SwitchLanguage(string culture)
  {
      Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
      Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
  }
  </code></pre>
  
  <p>As far as I understand, this should be enough to make the pages based on my master page exhibit a localised behaviour, i.e. get their resources from the appropriate local <code>resx</code> file according to culture. However, it is not working. They always appear in Spanish, which is my browser's default language. I have set some trace messages at the entry and exit points of <code>SwitchLanguage</code>, and apparently the current thread is not changing its culture info: every time <code>SwitchLanguage</code> is called, the current thread's culture is "es-ES", regardless of what my code has just set.</p>
  
  <p>Is there any problem with my code or with the approach I am taking? Thanks.</p>