title: MVC3 globalization: need global filter before model binding
body: <p>Currently, I have a global filter called <code>GlobalizationFilter</code> that checks the route values, cookies and browser languages header to determine the correct culture settings for the request:</p>
  
  <pre><code>public override void OnActionExecuting(ActionExecutingContext filterContext)
  {
      // determine cultureInfo
      Thread.CurrentThread.CurrentCulture = cultureInfo;
      Thread.CurrentThread.CurrentUICulture = cultureInfo;
  }
  </code></pre>
  
  <p>It all works, but the model binding process seems to occur before the global filters, and so the model binder doesn't take the culture settings into account. </p>
  
  <p>This leads to problems with interpreting double values, <code>DateTime</code> values etc.</p>
  
  <p>I could move the culture detection code to other locations, but I don't like any of my options:</p>
  
  <ul>
  <li><p>Application's <code>BeginRequest</code> event. At this point of time the routing hasn't occurred, so I'll have to manually fish out the <code>/en-US/</code> culture token from the URL. This in unacceptable.</p></li>
  <li><p>Controller's <code>Initialize()</code> method. This will force me to write a base class for all my controllers, and inherit the existing controllers from it. I don't like this, but I'll opt for this solution if nothing better comes up.</p></li>
  </ul>
  
  <p>Ideally, I want to find some way to inject my code between the "routing complete" and "model binding starts" events, but I found nothing in MSDN / Google on this.</p>
  
  <p>Or maybe there's some other way to handle MVC3 globalization that I'm unaware of?</p>
  
  <p>Thanks in advance for any contribution.</p>