title: Asynchronous Controller is blocking requests in ASP.NET MVC through jQuery
body: <p>I have just started using the AsyncController in my project to take care of some long-running reports. Seemed ideal at the time since I could kick off the report and then perform a few other actions while waiting for it to come back and populate elements on the screen.</p>
  
  <p>My controller looks a bit like this. I tried to use a thread to perform the long task which I'd hoped would free up the controller to take more requests:</p>
  
  <pre><code>public class ReportsController : AsyncController
  {
      public void LongRunningActionAsync()
      {
          AsyncManager.OutstandingOperations.Increment();
  
          var newThread = new Thread(LongTask);
          newThread.Start();
      }
  
      private void LongTask()
      {
          // Do something that takes a really long time
          //.......
  
          AsyncManager.OutstandingOperations.Decrement();
      }
  
      public ActionResult LongRunningActionCompleted(string message)
      {
          // Set some data up on the view or something...
  
          return View();
      }
  
      public JsonResult AnotherControllerAction()
      {
          // Do a quick task...
  
          return Json("...");
      }
  }
  </code></pre>
  
  <p>But what I am finding is that when I call LongRunningAction using the jQuery ajax request, any further requests I make after that back up behind it and are not processed until LongRunningAction completes. For example, call LongRunningAction which takes 10 seconds and then call AnotherControllerAction which is less than a second. AnotherControllerAction simply waits until LongRunningAction completes before returning a result.</p>
  
  <p>I've also checked the jQuery code, but this still happens if I specifically set "async: true":</p>
  
  <pre><code>$.ajax({
      async: true,
      type: "POST",
      url: "/Reports.aspx/LongRunningAction",
      dataType: "html",
      success: function(data, textStatus, XMLHttpRequest) { 
             // ...
          },
      error: function(XMLHttpRequest, textStatus, errorThrown) { 
         // ...
      }
  });
  </code></pre>
  
  <p>At the moment I just have to assume that I'm using it incorrectly, but I'm hoping one of you guys can clear my mental block!</p>