有没有办法可以使用新IHttpActionResult界面返回HttpStatusCode.NoContent响应消息?
我目前正在使用return new HttpResponseMessage( HttpStatusCode.NoContent );
并希望将其转换为return NoContent();.
IHttpActionResult已经得到了Ok(),Conflict()并且NotFound()但是我找不到任何的Forbidden()和NoContent()我需要在我的项目中使用.
添加其他结果类型有多容易?
如何从WebAPI方法返回HTTP 403?我试过用HttpStatusCode.Forbidden抛出一个HttpResponseException,我试过了
return request.CreateErrorResponse(HttpStatusCode.Forbidden, pEx);
Run Code Online (Sandbox Code Playgroud)
两者都不奏效.两者总是返回HTTP 200.我错过了什么?它必须是简单的东西,但我没有看到它.