500 Internal Server Error in ASP.NET MVC

I am working in ASP.NET MVC. I am using partial views, but when I clicked on particular link I got the following error.

500 Internal Server Error

How can this error be fixed?


Solution 1:

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.

Solution 2:

500 Server error means that a script has thrown an error, this is not a broken link (aka a 404 error).

If you are using Internet Explorer, go to tools > options > advanced and unselect friendly http errors, this will give you a more comprehensive description of the error so you can debug the script, or contact the relevant people to debug it.

Solution 3:

I got more details of the error from windows event viewer(Run>eventvwr.msc>Windows Logs>Application). Check the warnings/errors recorded from w3wp.exe

In my case the reason was missing dlls. Hope this helps