500 Internal Server Error in ASP.NET MVC

To check what causes Internal Server 500 Error under ASP MVC you can also run your app in debug mode and check property AllErrors.
The property is an array of Exception type elements.

To do this open Global.asax.cs (C#) and in the body of class MvcApplication put method Application_EndRequest:

protected void Application_EndRequest()
{   //here breakpoint
    // under debug mode you can find the exceptions at code: this.Context.AllErrors
}

Then set breakpoint and check contents of the array: this.Context.AllErrors

It helped me to resolve what exception was thrown and optionally to see the stacktrace.

Leave a Comment