Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web API: Non-descriptive 500 Internal Server Error

As title says, I’ve got 500 Internal Server Error from GET request to an IQueryable action. The body of the error is empty. That error happens after my action returns result.

I use ASP.NET Web API RC.

How can I get stack trace of that error?

like image 324
oddy Avatar asked Jun 08 '12 07:06

oddy


People also ask

How do I fix 500 internal server error IIS?

IIS error The error 500.19 is an internal server error often occurring on a server using Microsoft IIS software. It indicates that the configuration data for the page is invalid. To solve the issue, delete the malformed XML element from the Web. config file or from the ApplicationHost.


1 Answers

You can try adding:

GlobalConfiguration.Configuration.IncludeErrorDetailPolicy =      IncludeErrorDetailPolicy.Always; 

to your Application_Start() in the Global.asax. This solution works for many of the common errors.

If, however, you aren't getting satisfactory information you should consider writing an l Exception Filter and registering it globally.

This article should get you started. The core of what you need is to write & register something like:

public class NotImplExceptionFilter : ExceptionFilterAttribute {   public override void OnException(HttpActionExecutedContext context) {      if (context.Exception is NotImplementedException) {        context.Response = new HttpResponseMessage(HttpStatusCode.NotImplemented);     }   } } 
like image 76
Stever B Avatar answered Oct 02 '22 06:10

Stever B