I\'m working on a service in WebAPI 2, and the endpoint currently returns an IHttpActionResult
. I\'d like to return a status code 422
, but since it\'s
Another simplified example:
public class MyController : ApiController
{
public IHttpActionResult Get()
{
HttpStatusCode codeNotDefined = (HttpStatusCode)422;
return Content(codeNotDefined, "message to be sent in response body");
}
}
Content
is a virtual method defined in abstract class ApiController
, the base of the controller. See the declaration as below:
protected internal virtual NegotiatedContentResult Content(HttpStatusCode statusCode, T value);