Return content with IHttpActionResult for non-OK response

前端 未结 15 2237
北恋
北恋 2020-11-28 17:55

For returning from a Web API 2 controller, I can return content with the response if the response is OK (status 200) like this:

    public IHttpActionResult          


        
15条回答
  •  没有蜡笔的小新
    2020-11-28 18:40

    Sorry for the late answer why don't you simple use

    return BadRequest("your message");

    I use it for all my IHttpActionResult errors its working well

    here is the documentation : https://msdn.microsoft.com/en-us/library/system.web.http.apicontroller.badrequest(v=vs.118).aspx

提交回复
热议问题