Jul 18, 2012 at 1:58 PM
Edited Jul 18, 2012 at 2:00 PM
|
Apparently, I can throw an HttpResponseException inside a controller action by sticking a 200 HttpResponseMessage into it.
public class CarsController : ApiController {
public string[] GetCars() {
//throw the HttpResponseException
var response = new HttpResponseMessage(HttpStatusCode.OK);
throw new HttpResponseException(response);
}
}
And this gives me a 200 response back as result.
I see that the ApiControllerActionInvoker inspects the exception thrown inside the controller and if the exception type is HttpResponseException, it sets its Response property and passes it onto its caller.
Do u think that this is right? I mean it is all developer's fault if s/he throws an HttpResponseException with a successful status code but do u think the framework should do something to prevent it from going over the wire?
|