Ever since I started working an MVC project with ASYNC from start - all controllers, database calls, etc. are async and awaited I have been in debug hell. I never get helpful debug/exception information - it's lost in the bowels of the system. I have to go into ELMAH or AI to view the exception since it never bubbles up and ends the request.
In most cases, the page will just spin away until the browser gives up. Am I missing something somewhere? For instance, I have an error on the page (null reference), but since the page is async, I never see the exception.
Unlike most of the questions asked here that tend to cause a deadlock, there is no use of .Result anywhere in this codebase. This is async form the start and all the way through.
To clarify, here is the exact workflow of this MVC controller. I made a few changes to test when it hangs and when it doesn't.
Controller
public async Task<ActionResult> Review(Guid id)
{
var quote = await Quotes.GetQuoteById(id);
return View();
}
Service
return await Ef.DbSet.Where(d => d.Id == id).FirstOrDefaultAsync();
View (first line)
@{ throw new ApplicationException("you failed"); }
With the above setup I will never see the exception. It just hangs. However, if I change the controller to this:
return View();
var quote = await Quotes.GetQuoteById(id);
Then I get my exception. If I change the service to non-async I also get to the exception. Therefore, unlike the duplicate question referenced, I don't have an unawaited call anywhere. But the async/await is what is causing the browser to hang.
Is there a way to debug this? As an interesting aside, this only happens during debug, in production, the exception will get raised as expected.
Re-asked/Clarified/Non-Duplicate This was originally asked here but it was closed as duplicate of this question, but it isn't. Added clarification to show why it isn't. But since they closed as a definite duplicate, you can't even see it, so I had to ask as a new question.