Returning http status code from Web Api controller

前端 未结 13 1534
一生所求
一生所求 2020-11-27 10:01

I\'m trying to return a status code of 304 not modified for a GET method in a web api controller.

The only way I succeeded was something like this:

p         


        
13条回答
  •  一整个雨季
    2020-11-27 10:51

    If you need to return an IHttpActionResult and want to return the error code plus a message, use:

    return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotModified, "Error message here"));
    

提交回复
热议问题