title: MVC 4.5 Async Ajax call not working
body: <p>I have a slow running action on a controller that I've converted to the new Async method. It now runs much faster, however any jQuery Ajax calls to it return the following string,</p>
  
  <pre><code>System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]
  </code></pre>
  
  <p>instead of waiting for the async to complete. </p>
  
  <p>What am I doing wrong here? I've followed every example I can find and this isn't rocket science to implement.</p>
  
  <p>Pretty much followed what is outlined in this video</p>
  
  <p><a href="http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2287" rel="noreferrer">http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2287</a></p>
  
  <p>And this link too</p>
  
  <p><a href="http://www.asp.net/mvc/tutorials/mvc-4/using-asynchronous-methods-in-aspnet-mvc-4#CreatingAsynchGizmos" rel="noreferrer">http://www.asp.net/mvc/tutorials/mvc-4/using-asynchronous-methods-in-aspnet-mvc-4#CreatingAsynchGizmos</a></p>
  
  <p>I understand that the Async doesn't change HTTP, but what I was expecting was for the long runnning Ajax call to work in the background, and then return to the user the result when it was finished. This would then free up the server to process additional ajax calls instead of blocking them.</p>
  
  <p>Update:</p>
  
  <p>Here is the javascript code</p>
  
  <pre><code>function doWork(options){
      return $.ajax("/getData", {
                      contentType: 'text/json',
                      async: true,
                      success: $.proxy(options.callback, options.scope),
                      error: function (jqXHR, textStatus, error) {
                          options.callback.apply(options.scope, [error, textStatus, jqXHR]);
                      }
                  });
  }
  </code></pre>
  
  <p>And here is my controller action in C#</p>
  
  <pre><code>[HttpGet]
  [AsyncTimeout(60000)]
  public async Task&lt;ActionResult&gt; GetData()
          {
              RestResponse&lt;Data&gt; response = new RestResponse&lt;Data&gt;();
  
              try
              {
                  Data result = null;
  
                  await Task.Factory.StartNew(() =&gt;
                  {
                      result = ServerImpl.RetrieveData();
                  });
  
                  response.Value = result;
                  response.HttpStatusCode = 200;
              }
              catch (Exception ex)
              {
                  response.HttpStatusCode = 500;
                  response.Value = null;
              }
  
              return Json(response, JsonRequestBehavior.AllowGet);
          }
  </code></pre>