经过一些谷歌搜索,我了解到这是一种在api控制器中处理错误的正确方法,通过抛出带有适当状态代码的HttpResponseException: 控制器动作方法: [System.Web.Http.Authorizeuncomment this block to test exception throw
var response = new HttpResponseMessage(HttpStatusCode.NotFound"some error message", System.Text.Encoding.UTF