May 22, 2012 at 8:59 PM
Edited May 22, 2012 at 9:10 PM
|
I have been thinking of custom HTTP statuses but in ASP.NET Web API it is not possible - or I have not found a way. While HTTP spec allows for custom status codes (in the range not already specified), we are tied down to the HttpStatusCode enumeration.
In the ASP.NET MVC, we could use a HttpStatusResult (or similar name) with an integer but in Web API I cannot find a way. Is there a way possible to set status to custom code?
Thanks
|
|
Coordinator
May 22, 2012 at 9:14 PM
|
I believe casting your custom status code to HttpStatusCode works even if the enum does not currently define your status code.
Daniel Roth
|
|
May 22, 2012 at 9:25 PM
Edited May 22, 2012 at 9:26 PM
|
Daniel is correct. You can always do something like
new HttpResponseMessage((HttpStatusCode)789);
|
|
May 22, 2012 at 9:43 PM
Edited May 22, 2012 at 9:59 PM
|
Wow... how did I not know this. Thanks!
|
|