title: Runtime error in MVC 5 razor view hangs IIS when using an async action
body: <p>I've noticed that if a runtime error is encountered in a Razor View that was served from an asynchronous controller action (i.e., <code>Task&lt;ActionResult&gt;</code>) the exception hangs the web application. I'm only able to flush it out by restarting IIS. What's annoying here is that because the error is not occurring within the async IO (that is, within the API call to the database) but within the Razor View the exception seems to be swallowed by the thread. I was only able to diagnose that the View was the cause by removing the async from the API call and the controller, at which point the runtime error on the View manifested itself.</p>
  
  <p>My question is, is there a way to avoid these deadlock situations with asynchronous controller actions? I tried adding the synchronization context setting to web.config, as well as appending <code>ConfigureAwait(false)</code> to the API async call, to no avail. It seems that as the error was generated on the View, and not within the API call, these measures were too early to handle the exception.</p>
  
  <p>I am using MVC 5.2.3 running on .NET 4.0.30319</p>