Reputation: 45135
From http://www.asp.net/web-api/overview/web-api-routing-and-actions/exception-handling
HttpResponseException
What happens if a Web API controller throws an exception? By default, most exceptions are translated into an HTTP response with status code 500, Internal Server Error.
The HttpResponseException type is a special case. This exception returns any HTTP status code that you specify in the constructor of the exception.
Except that it doesn't. Fiddler shows me a 500 is returned.
However, HttpException seems to do what that article says.
Is the documentation wrong or am I missing something?
UPDATE
While typing that out, I had an idea. I tried both from two controllers, an ApiController and a standard MVC controller.
The two exception work in reverse to each other depending on the type of controller they're thrown from.
Upvotes: 17
Views: 6010
Reputation: 45135
[Moved my update to an answer]
While typing that out, I had an idea. I tried both from two controllers, an ApiController and a standard MVC controller.
The two exception work in reverse to each other depending on the type of controller they're thrown from.
Upvotes: 21