I am looking for, but not finding, a list of all acceptable return options for IHttpActionResult. I know of these two:
- OK(object)
- NotFound()
Are there more? And where are they documented?
I am looking for, but not finding, a list of all acceptable return options for IHttpActionResult. I know of these two:
Are there more? And where are they documented?
There are tons:
See: https://msdn.microsoft.com/en-us/library/system.web.http.results(v=vs.118).aspx
This one is my favorite because you can put custom return codes in it e.g.: NoContent 204
https://msdn.microsoft.com/en-us/library/system.web.http.results.statuscoderesult(v=vs.118).aspx
Example:
public async Task<IHttpActionResult> DoIt()
{
return StatusCode(HttpStatusCode.NoContent);
}
Basically all http error codes are supported, I would advise to stick with them for compliance reasons.
Is this what you're looking for?
https://msdn.microsoft.com/en-us/library/system.net.httpstatuscode(v=vs.118).aspx
All of those methods are implemented by ApiController
, the base class for your Web API controllers.
https://msdn.microsoft.com/en-us/library/system.web.http.apicontroller(v=vs.118).aspx
Every method on that page with a description that starts with "Creates a" is such a method.