views:

39

answers:

1

Hi guys,

Is it possible to inject behavior for whole controller, like it could be done for action with ActionFilterAttribute

Best regards, Alexey Zakarov

A: 

I may not understand the question correctly, but I think that you are asking if you can have an action filter attached to the entire class? If so the answer is yes, for example the [Authorize] attribute. (you can obviously create your own.)

The controller can also override the OnActionExecuting/Executed + OnResultExecuting/ OnResultExecuted. (Expand that to inheritance and you can have derived controllers all doing the same thing.)

AJ
I don't want to override controller methods. I want to specify filter attribute that whould override OnActionExecuting behavior. But it will do it for all action of controllers.
Alexey Zakharov
What AJ is saying is that you can stick your [Filter] on the controller type, and it will apply to all actions within that controller.
Levi
Thanks you AJ and Levi! Now everything is clear
Alexey Zakharov