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

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);
    }
  }
}

Leave a Comment