Last post Jan 25, 2016 09:42 AM by Chris Zhao
Jan 22, 2016 03:05 PM|suneeswe|LINK
What's the advantage of returning the below result rather than this.ok(result);
return new ResponseMessageResult(this.request.CreateResponse(HttpStatusCode.OK, result));
we are upgraded web api 2
My controler is method is
public async Task<IHttpActionResult> Get()
if i use new ResponseMessageResult it's very difficult to me unit testing the result.
Your suggestions would be much appriciated.
Jan 25, 2016 09:42 AM|Chris Zhao|LINK
In the below, I have listed some advantages about HttpResponseMessage and IHttpActionResult for your reference.
•Useful when you are trying to use your controller layer as the translation between the HTTP protocol .
•Easy to set caching headers
•Direct control over the HTTP payload and headers
•Simplifies unit testing your controllers.
•Moves common logic for creating HTTP responses into separate classes.
•Makes the intent of the controller action clearer, by hiding the low-level details of constructing the response.
More detailed information about action results in Web API 2 in the below link: