title: Asp MVC and Web Api Async Controllers
body: <p>I was working with Asp MVC 3, and in my application was created Async controller with some methods like: </p>
  
  <pre><code>public void ActionAsync()
  {
     AsyncManager.OutstandingOperations.Increment(); 
     AsyncManager.Parameters["someResult"] = GetSomeResult();
     AsyncManager.OutstandingOperations.Decrement();
  }
  
  public JsonResult ActionCompleted(SometResultModel someResult)
  {
     return Json(someResult, JsonRequestBehavior.AllowGet);
  }
  </code></pre>
  
  <p>And now, when I'm working with MVC4 and Web Api I need to create controller with async actions like in mvc 3. At current time it's looks like: </p>
  
  <pre><code>public Task&lt;HttpResponseMessage&gt; PostActionAsync()
  {
       return Task&lt;HttpResponseMessage&gt;.Factory.StartNew( () =&gt;
             {
                var result = GetSomeResult();
                return Request.CreateResponse(HttpStatusCode.Created, result);
             });
  }
  </code></pre>
  
  <p>Is it a good idea to make async actions in web api like this or there some better way is exist?</p>
  
  <p>UPD. Also, if I will use</p>
  
  <pre><code>public async Task&lt;HttpResponseMessage&gt; ActionAsync()
  {
     var result = await GetSomeResult();
     return Request.CreateResponse(HttpStatusCode.Created, result);
  }
  </code></pre>
  
  <p>will this full action work in background thread? And how to make my <code>GetSomeResult()</code> function be awaitable? It's return that <code>Task&lt;HttpResponseMessage&gt;</code> is not awaitable.</p>