I'm sure this is simple but ... how are you meant to raise a HTTP 500 within a web service which returns a IHttpActionResult
.
I can return a System.Web.Http.Results.Ok
and end up with 200 client side but I can't find how to return anything other than a 200.
I've tried
HttpStatusCodeResult r = new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "BOO");
which is the right idea but I can't work out how to cast a HttpStatusCodeResult
to IHttpStatusCodeResult
.
I've also tried changing the return type to HttpStatusCodeResult
(so I can use the above) but when I do that the jQuery on the client sees the result as a 'success' (even though with the Javascript you can see 'StatusCode' as 500 and the 'StatusDescription' as 'BOO'.
All I really want to do is :
- be free to return any HTTP return value
- include a message with it
- have jQuery recognise that some HTTP returns should be handled by .done and others by .fail
Thanks.