ASP.NET Web Api HttpResponseException 400 (Bad Request) Hijacked by IIS

前端 未结 6 2120
庸人自扰
庸人自扰 2020-12-15 05:56

I\'m writing a Web API service and trying to return a (400) Bad Request if my ModelState is invalid. I do not want a response body to be attached to this. It appears that II

6条回答
  •  一个人的身影
    2020-12-15 06:38

    Usually in such cases it is enough to set TrySkipIisCustomErrors = true on response object, but in case of Web API it sometimes doesn't do the trick (Web API even tries to set this flag internally by itself). For situations like this you can consider changing the IIS configuration. Please take a look here (you should be mostly interested in existingResponse="PassThrough").

提交回复
热议问题