title: ASP.Net WebAPI ExecuteAsync ends before controller action executes
body: <p><em>First I would like to note that my problem is probably environment/project specific and can be difficult to solve basing only on code I show - I'm aware of this, but I've run out of ideas what can be wrong and I need to ask for help.</em></p>
  
  <p>I've got legacy project. There are WebApi controllers:</p>
  
  <ol>
  <li><p>BaseApiControl</p>
  
  <pre><code>public abstract class BaseApiController : ApiController
  {
      public override Task&lt;HttpResponseMessage&gt; ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext controllerContext, CancellationToken cancellationToken)
      {
          return base.ExecuteAsync(controllerContext, cancellationToken);
      }
  }
  </code></pre></li>
  <li><p>TokenAuthorizeAttribute:</p>
  
  <pre><code>[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
  public class TokenAuthorizeAttribute : AuthorizeAttribute
  {
      public override void OnAuthorization(HttpActionContext actionContext)
      {
          // authorization... if succeed culture is set:
  
          Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("de");
  
          return;
      }
  }
  </code></pre></li>
  <li><p>ValuesController:</p>
  
  <pre><code>public class ValuesController : BaseApiController
  {
      [TokenAuthorize]
      [HttpGet]
      [Route("api/values")]
      public IEnumerable&lt;string&gt; Get()
      {
          var c = Thread.CurrentThread.CurrentUICulture;
          var b = Thread.CurrentThread.CurrentCulture;
  
          return new string[] { "value1", "value2" };
      }
  }
  </code></pre></li>
  </ol>
  
  <p>The problem is that even I set culture in TokenAuthorizeAttribute in controller Get action the old one culture is presented, not the one I set in TokenAuthorizeAttribute. </p>
  
  <p>I assume that this is because of Execute<strong>Async</strong> method which calls filters on other threads, so culture in the TokenAuthorizeAttribute is set for another thread.</p>
  
  <p>I've made an experiment and copied this code to new WebApi project and what turns out - everything is working fine. I was wondering why it can be like that. I found out that in newly created project the request flow is following:</p>
  
  <ol>
  <li>BaseApiController.ExecuteAsync method starts execution</li>
  <li>TokenAuthorizeAttribute.OnAuthorization method is executed</li>
  <li>ValuesController.Get method is executed</li>
  <li>BaseApiController.ExecuteAsync method ends execution</li>
  </ol>
  
  <p>while in my legacy project the flow is following:</p>
  
  <ol>
  <li>BaseApiController.ExecuteAsync method starts execution</li>
  <li>TokenAuthorizeAttribute.OnAuthorization method is executed</li>
  <li>BaseApiController.ExecuteAsync method ends execution</li>
  <li>ValuesController.Get method is executed</li>
  </ol>
  
  <p>I was really surprised. Does anyone have any idea why this request processing flow can differs? I've already checked out web.config and global.asax.cs and disabled all custom configuration like http modules, message handlers, formatters etc. but nothing helps.</p>