HTTPError Exception Message not displaying when webapi is run on Server vs being run locally

前端 未结 2 1044
囚心锁ツ
囚心锁ツ 2020-12-24 12:22

I have a webapi that runs on an IIS7.5 server. It has 3 controllers, and all 3 can be used to access the webapi from calls within my application.

I had a error wher

相关标签:
2条回答
  • 2020-12-24 12:34

    I found that these needed to be turned on in the GlobalConfiguration for the webapi itself:

    1: config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.LocalOnly;
    2: config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
    3: config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Never;
    

    The server actually determines how much detail to display, the default is LocalOnly.

    Our logging method is not considered local, I guess because it is not actually built into the API itself, but because it is in a shared dll between multiple APIs.

    I found this article to be very helpful.

    0 讨论(0)
  • 2020-12-24 12:38

    I used this one:

    GlobalConfiguration.Configuration.IncludeErrorDetailPolicy
              = IncludeErrorDetailPolicy.Always; 
    

    in Global of API and it's succeed.

    0 讨论(0)
提交回复
热议问题