ASP .NET Web API - Error Messages

Discussion in 'General troubleshooting' started by scurrvy, May 26, 2012.

  1. Hey guys,

    This post is a PSA for troubleshooting error messages in a hosted environment. Hopefully this will help the next person who may need to dig into why a server request is returning Error 500.

    Basically the ASP .NET Web API wasn't respecting my web.config settings to turn off custom errors and show the actual error message I was receiving during a POST request. The reason behind this lies with the Web API being designed to run outside of IIS. Yes, self-hosted, which is pretty awesome.

    One approach that worked for me was to turn on error detail at the global level. I added the following to my Global.asax file:

    Code:
    GlobalConfiguration.Configuration.IncludeErrorDetailPolicy 
        = IncludeErrorDetailPolicy.Always;
    Obviously this required a recompile and push so use with caution. The following blog post by the guys at Los Techies describes the issue in detail and offers up a more elegant solution.

    That's it. It took me 4 hours to figure out how to get the detailed error message and about 5 mins to copy the missing DLL up to the server. I was using Nuget to pull in some Beta Web API references and missed copying them when I published. Hopefully this will save the next guy some time!

    (first post)
     
  2. ComputerMan

    ComputerMan Winhost Staff

    Very cool! Thanks for posting :)
     

Share This Page