If your web application has both classic MVC controllers and web API controllers and you want to apply one Action Filter to both, then you need to be careful about the two types of IActionFilter interfaces that need to be used. At first, I thought writing standard MVC action filter should work but then learned otherwise through bitter experience of debugging :).
System.Web.Http.Filters.IActionFilter -[ System.Web.Http assembly]
Both interfaces are named IActionFilter but have different definitions and reside in different assemblies. This is so because even the base classes for classic MVC controller and ApiController reside in different assemblies too.
Learning: If your web application has both ApiController and Controller then you will need to have two different implementation (at least two different placeholder classes) if you want to apply common Action Filter logic.
No comments:
Post a Comment