In Asp.net Web Api, how do I set the status code of my response using an int or string, not the StatusCode enum?
In my case, I\'d like to return validation errors with
You can cast any int to a HttpStatusCode.
response.StatusCode = (HttpStatusCode)422;
You can also:
HttpResponseMessage response = Request.CreateResponse((HttpStatusCode)422, "Unprocessable Entity");