title: ASP.NET language setting in master page
body: <p>I am building a website with multiple language support.
  For this I have a link button on my master page.</p>
  
  <p>I have created a new base class to inherit from.
  I have set the CurrentUICulture and CurrentCulture in the Global.asax file.
  I have created resource files of the masterpage.
  I have set the globalisation line in the webconfig file.
  Both culture and uiculture as set to "auto"</p>
  
  <p>My master page is called "masterpage.master"
  I have two resource files: <code>masterpage.master.en-gb.resx</code> and <code>masterpage.master.nl-nl.resx</code>. (I also tried with en-GB and nl-NL)</p>
  
  <p>I created the masterpage initially in English.
  I use a cookie to store the chosen language. By default the cookie will be set to "en-GB" but for testing I set it to "nl-NL".</p>
  
  <p>The cookie is created and with testing I saw the culture is being set to <code>nl-NL</code>.</p>
  
  <p>Yet.... the link-buttons text is not changing. It shows the en-GB text and not the nl-NL text.</p>
  
  <p>What have I missed?
  How does the website select the right resx file? Is that done automatically based on the language and country setting in the file name or do I have to point that out?</p>
  
  <p>The markup of the link button:</p>
  
  <pre><code>&lt;asp:LinkButton ID="lbCHangeLanguage" runat="server" CssClass="lbCHangeLanguage" OnClientClick="javascript:return confirm('If you continue any unsaved changes will disappear!\n\nPress OK to continue.')" meta:resourcekey="lbCHangeLanguageResource1" Text="CHANGE LANGUAGE"&gt;&lt;/asp:LinkButton&gt;
  </code></pre>
  
  <p>In global.asax:</p>
  
  <pre><code> Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
  ' Fires at the beginning of each request
  
  Dim myLangCookie As HttpCookie
  myLangCookie = Request.Cookies.Get("FASTLANG")
  
  If myLangCookie Is Nothing Then
    myLangCookie = New HttpCookie("FASTLANG")
    myLangCookie.Values.Add("language", Languages.Dutch)
    myLangCookie.Secure = False
    If Request.Url.OriginalString.Contains("localhost") = False Then myLangCookie.Secure = True
    If Request.Url.OriginalString.ToLower.Contains("fasttest") = True Then myLangCookie.Secure = False
    myLangCookie.Expires = Now.AddYears(50)
    Response.Cookies.Add(myLangCookie)
  End If
  
  Dim myLang As String = myLangCookie.Values("language")
  Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo(myLang)
  Thread.CurrentThread.CurrentCulture = New Globalization.CultureInfo(myLang)
  </code></pre>
  
  <p>End Sub</p>
  
  <p>in web.config:</p>
  
  <pre><code>&lt;globalization  enableClientBasedCulture="true" culture="auto" uiCulture="auto"  requestEncoding="utf-8" responseEncoding="utf-8"  /&gt;
  </code></pre>