title: Unhandled exception crashes Web API service when thrown in async void action
body: <p>According to <a href="http://www.asp.net/web-api/overview/web-api-routing-and-actions/exception-handling" rel="noreferrer">documentation</a> <code>HttpResponseException</code> are handled by Web API automatically and Web API should just return <code>HttpResponseMessage</code> to client with corresponding <code>HttpStatusCode</code>. And it works... usually. </p>
  
  <p>But if we throw <code>HttpResponseException</code> from an action marked with <code>async</code> then this just doesn't work and <code>HttpResponseException</code> just crashes the whole service with something like "Exception has been unhandled by user code" message. Adding custom exception filter doesn't solve the problem as Web API doesn't catch <code>HttpResponseException</code> message.</p>
  
  <p><strong>Update 1</strong>
  I've investigated further and have found out that as soon as you add <code>await</code> modifier to an action, then every unhandled exception from this action crashes Web API service. And no ExceptionFilterAttributes are involved, Web API just doesn't execute them. You even don't have to thrown exception from really asynchronous code, it is enough to add <code>async</code> to action to cause every exception be totally unhandled.</p>
  
  <p>Here, this works ok, the exception can be caught by some exception filter:</p>
  
  <pre><code>public void Test()
  {
      throw new Exception("Hello");
  }
  </code></pre>
  
  <p>And this causes service to crash:</p>
  
  <pre><code>public async void Test()
  {
      throw new Exception("Hello");
  }
  </code></pre>
  
  <p><strong>Update 2</strong>
  Well, looks like everything works fine if we change <code>void</code> to some real type, here:</p>
  
  <pre><code>public async Task&lt;int&gt; Test()
  {
      throw new Exception("Hello");
  }
  </code></pre>
  
  <p>So, looks like unhandled exception from <code>async void</code> cause service to crash, but <code>async Task&lt;SomeType&gt;</code> works well, exception filters catch everything except <code>HttpResponseException</code> and <code>HttpResponseException</code> is correctly handled by Web API.</p>
  
  <p>Looks like I've just talked to myself, but it would be interesting to find out <strong>why exceptions in <code>async void</code> actions can't be handled correctly?</strong></p>