Error messages returned from Web API method are omitted in non-dev environment

后端 未结 5 2052
臣服心动
臣服心动 2020-12-29 22:21

I have a Web API controller POST method that behaves fine locally and on the testing server. If everything goes well it returns:

new HttpResponseMessage( Htt         


        
5条回答
  •  别那么骄傲
    2020-12-29 22:57

    Take a look at this MSDN post on the HttpConfiguration.IncludesErrorDetailPolicy:

    In your Global.asax:

    var config = GlobalConfiguration.Configuration;
    config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
    

    I have used this configuration property to force error messages to include details.

提交回复
热议问题