How to disable a global filter in ASP.Net MVC selectively

You could write a marker attribute: public class SkipMyGlobalActionFilterAttribute : Attribute { } and then in your global action filter test for the presence of this marker on the action: public class MyGlobalActionFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.ActionDescriptor.GetCustomAttributes(typeof(SkipMyGlobalActionFilterAttribute), false).Any()) { return; } // here do whatever you were intending … Read more

Injecting dependencies into ASP.NET MVC 3 action filters. What’s wrong with this approach?

Yes, there are downsides, as there are lots of issues with IDependencyResolver itself, and to those you can add the use of a Singleton Service Locator, as well as Bastard Injection. A better option is to implement the filter as a normal class into which you can inject whichever services you’d like: public class MyActionFilter … Read more