title: Best place to set CurrentCulture for multilingual ASP.NET MVC web applications
body: <p>For multilingual ASP.NET MVC 3 web application, I am determining the <code>Thread.CurrentThread.CurrentCulture</code> and <code>Thread.CurrentThread.CurrentUICulture</code> on the controller factory as follows:</p>
  
  <pre><code>public class MyControllerFactory : DefaultControllerFactory {
  
      protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) {
  
          //Get the {language} parameter in the RouteData
          string UILanguage;
          if (requestContext.RouteData.Values["language"] == null)
              UILanguage = "tr";
          else
              UILanguage = requestContext.RouteData.Values["language"].ToString();
  
          //Get the culture info of the language code
          CultureInfo culture = CultureInfo.CreateSpecificCulture(UILanguage);
          Thread.CurrentThread.CurrentCulture = culture;
          Thread.CurrentThread.CurrentUICulture = culture;
  
          return base.GetControllerInstance(requestContext, controllerType);
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p><em>The above code is nearly a year old now! So, I open for suggestions.</em></p>
  </blockquote>
  
  <p>And I register this on the Global.asax file like:</p>
  
  <pre><code>ControllerBuilder.Current.SetControllerFactory(new MyControllerFactory());
  </code></pre>
  
  <p>This is working good but I am not sure if it is the best practice and best place to do this type of action. </p>
  
  <p>I haven't dug into the main role of <code>ControllerFactory</code> and I am unable to compare it against <code>ActionFilterAttribute</code>.</p>
  
  <p>What do you think about the best place to do this type of action?</p>