title: Change culture based on a link MVC4
body: <p>I have a curiosity related to culture change in MVC. I tried in 2 ways, but apparently I was wrong somewhere.</p>
  
  <p>In my Web.config I have :</p>
  
  <pre><code> &lt;globalization uiCulture="auto" culture="auto" /&gt;
  </code></pre>
  
  <p>This is how I tried to change the thread culture :</p>
  
  <pre><code> &lt;li&gt;@Html.ActionLink("Eng", "ChangeCulture", "Home", new { lang="en-US"}, new { @class = "languageSelectorEnglish" })&lt;/li&gt;
  </code></pre>
  
  <p><strong>First method</strong></p>
  
  <p>I have the following controller :</p>
  
  <pre><code>    public void ChangeCulture(string lang)
      {
          Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(lang);
          Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang);
  
          Response.Cookies.Remove("Language");
          var langCookie = new HttpCookie("Language");
          langCookie["Language"] = lang;
          langCookie.Value = lang;
          langCookie.Expires = System.DateTime.Now.AddDays(21);
          Response.Cookies.Add(langCookie);
  
          Response.Redirect(Request.UrlReferrer.ToString());
      }
  </code></pre>
  
  <p><strong>Second method</strong></p>
  
  <pre><code>    public ActionResult ChangeCulture(string lang)
      {
          Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(lang);
          Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang);
  
          // Split the url to url + query string
          var fullUrl= Request.UrlReferrer.ToString();
          var questionMarkIndex = fullUrl.IndexOf('?');
          string queryString = null;
          string url = fullUrl;
          if (questionMarkIndex != -1) // There is a QueryString
          {
              url = fullUrl.Substring(0, questionMarkIndex);
              queryString = fullUrl.Substring(questionMarkIndex + 1);
          }
  
          // Arranges
          var request = new HttpRequest(null, url, queryString);
          var response = new HttpResponse(new StringWriter());
          var httpContext = new HttpContext(request, response);
  
          var routeData = RouteTable.Routes.GetRouteData(new HttpContextWrapper(httpContext));
  
          // Extract the data    
          var values = routeData.Values;
          var controllerName = values["controller"];
          var actionName = values["action"];
          var areaName = values["area"];
  
          return RedirectToAction(actionName.ToString());
      }
  </code></pre>
  
  <p>Where am I wrong ? Thank you.</p>