I have a base controller from which every other controller inherits. I would like to create a method in there that will be executed in each view. Right now I have void method in Base controller that I just call in every action in every controller.
Is that even possible to do?
Thank you,
H
The easiest way to do this is with an
ActionFilterAttributeand in MVC3 you can register the attributes globally or per controller. You do not need to use a base controller.You can define your attribute:
And then add it globally in your Global.asax.cs:
To use it on every action in a controller use: