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() Ok(data) |
302 | Temporary Redirection | Redirect(target) RedirectToRoute(name, props) |
400 | Bad Request | BadRequest() BadRequest(message) BadRequest(model) |
404 | Not Found | NotFound() |
409 | Conflict | Conflict() |
500 | Internal Server Error | InternalServerError() InternalServerError(Exception) |
Technorati Tags: WebAPI
No comments:
Post a Comment