locked
Cannot get verbose error messages RRS feed

  • Question

  • User-1732172875 posted

    I have a REST service I've put together that runs fine locally but not when hosted.

    When I send a request to the hosted service I get this response in Postman:

    {
    "Message": "Object reference not set to an instance of an object."
    }

    I've tried THREE different things to get more verbose error messages:

    1. Adding <customErrors mode="Off"/> to the Web.Config

    2. Adding GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; to Global.asax.cs

    3. Adding config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; to WebApiConfig.cs

    But I still get only the crude error message shown above when I attempt to call one of my methods from Postman.

    Of course the exception could be anywhere, within the action handler or somewhere else in the controller or action filters.

    Does anyone understand why we'd get just a basic one line error rather than stack traces etc, despite all of the above attempts?

    We don't get this particular error when we test locally on a developer PC so it's vital that we get more detail here.

    Thanks

    Wednesday, September 28, 2016 3:46 PM

Answers

  • User-1732172875 posted

    Hi,

    I've fixed this now - annoyingly there was one exception handler that was incorrectly suppressing the details of the exception so all we saw was the message!

    Thx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 29, 2016 3:54 PM

All replies

  • User36583972 posted

    Hi Hugo,

    Does anyone understand why we'd get just a basic one line error rather than stack traces etc, despite all of the above attempts?

    As far as I know, maybe your Web API has defined an exception error message. You can refer the following tutorials about how to handle exceptions in Web API and modify your controller's actions.

    Exception Handling in ASP.NET Web API:

    http://www.asp.net/web-api/overview/error-handling/exception-handling

    Global Error Handling in ASP.NET Web API 2:

    http://www.asp.net/web-api/overview/error-handling/web-api-global-error-handling

    You could also share us more relevant code/message to help us reproduce the problem.

    Best Regards,

    Yohann Lu

    Thursday, September 29, 2016 10:38 AM
  • User-1732172875 posted

    Hi,

    I've fixed this now - annoyingly there was one exception handler that was incorrectly suppressing the details of the exception so all we saw was the message!

    Thx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 29, 2016 3:54 PM