This project is read-only.

Register global action filters in modules?

Topics: Writing modules
Jul 9, 2012 at 5:18 PM

Hi there,

is there a way to register global action filters inside of a module?


Jul 9, 2012 at 5:30 PM

Sure, look for FilterProvider and IActionFilter subclasses.

Jul 9, 2012 at 5:41 PM

Thanks for the quick reply. I already had a look at them and also at some filters like ThemeFilter. But I couldn't find any way to register filters globally so they are used by all actions. Could you provide me one or two more hints that get me into right direction?!


Jul 9, 2012 at 5:46 PM

ThemeFilter is used by all actions because it implements IActionFilter. It is also registered automatically in Orchard because has it inherits from FilterProvider, it implements IDependency. 

Create a class that inherits from FilterProvider and implements IActionFilter. Put it in any module, done.

Jul 9, 2012 at 6:02 PM

Great, that did the trick! Hopefully I will be able to give something back to community in form of a new module soon :)