title: Starting and Forgetting an Async task in MVC Action
body: <p>I have a standard, non-async action like:</p>
  
  <pre><code>[HttpPost]
  public JsonResult StartGeneratePdf(int id)
  {
      PdfGenerator.Current.GenerateAsync(id);
      return Json(null);
  }
  </code></pre>
  
  <p>The idea being that I know this PDF generation could take a long time, so I just start the task and return, not caring about the result of the async operation.</p>
  
  <p>In a default ASP.Net MVC 4 app this gives me this nice exception:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked &lt;%@ Page Async="true" %>.</p>
  </blockquote>
  
  <p>Which is all kinds of irrelevant to my scenario. Looking into it I can set a flag to false to prevent this Exception:</p>
  
  <pre><code>&lt;appSettings&gt;
      &lt;!-- Allows throwaway async operations from MVC Controller actions --&gt;
      &lt;add key="aspnet:AllowAsyncDuringSyncStages" value="true" /&gt;
  &lt;/appSettings&gt;
  </code></pre>
  
  <p><a href="https://stackoverflow.com/a/15230973/176877">https://stackoverflow.com/a/15230973/176877</a><br/>
  <a href="http://msdn.microsoft.com/en-us/library/hh975440.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/hh975440.aspx</a></p>
  
  <p>But the question is, is there any harm by kicking off this Async operation and forgetting about it from a synchronous MVC Controller Action? Everything I can find recommends making the Controller Async, but that isn't what I'm looking for - there would be no point since it should always return immediately.</p>