Sunday, May 17, 2015

WebAPI IHttpActionResult vs HttpResponseMessage

The WebAPI Controller can return either HttpResponseMessage or IHttpActionResult. HttpResposeMessage converts it directly to an HTTP response message. Call ExecuteAsync to create an HttpResponseMessage then convert to an HTTP response message.

ApiController Action Result Methods by HTTP Status Code

Status Code Meaning Method
200 Operation successful Ok()
302 Temporary Redirection Redirect(target)
RedirectToRoute(name, props)
400 Bad Request BadRequest()
404 Not Found NotFound()
409 Conflict Conflict()
500 Internal Server Error InternalServerError()
Technorati Tags:

No comments:

Post a Comment