Return content with IHttpActionResult for non-OK response

前端 未结 15 2230
北恋
北恋 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:43

    You can also do:

    return InternalServerError(new Exception("SOME CUSTOM MESSAGE"));
    

提交回复
热议问题