I have a project running ASP.Net WebApi in a self hosted configuration and I am using an ActionFilterAttribute
class as a filter for some security checks and an ExceptionFilterAttribute
as the exception handling class.
When I raise an exception in my ApiController
of type HttpResponseException
it is being ignored by the ExceptionFilterAttribute
class as expected.
The issue is that when i raise an exception of type HttpResponseException
in the security filter of type ActionFilterAttribute
it is being caught by the ExceptionFilterAttribute
class.
When debugging I have found that that exception is being changed to
Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
What can I do to prevent this behavior.
This behavior seems like a bug. Could you share how your action filter looks like? By the way, setting the action filter actioncontext's Response property to the Http response would short-circuit the pipeline and wondering if you can avoid throwing HttpResponseException from the action filter.