When and why should we use WebApi Action Filter and DelegationHandler?

294 Views Asked by At

I am on a project that needs to have a cross-cutting error handling and response manipulation. I found there are Filters And Delegating Handlers, but I don't know the difference between these two, can someone help me please to figure this out?

1

There are 1 best solutions below

0
On BEST ANSWER

There is some info around this in SO such as

When to use HttpMessageHandler vs ActionFilter?

simply put:

  1. message handler comes earlier than filters - so can circuit out earlier
  2. message handler is more generic - process HTTP request
  3. filter on other hand are only applicable in Actions, hence more specific

so base on the characteristics and what you want, you choose which one fit the most

there is a stack diagram of the flow ASP.NET MVC4 Web API Stack Diagram

source from: https://blogs.msdn.microsoft.com/kiranchalla/2012/05/05/asp-net-mvc4-web-api-stack-diagram/