I have an authentication filter that I want to put on all my actions in a given controller.
Is it possible to add a filter at the controller level?
I have an authentication filter that I want to put on all my actions in a given controller.
Is it possible to add a filter at the controller level?
Yes, it's literally as simple as putting the ActionFilter attribute at the class level instead of the action level.
Yes. It is then applied to all actions automatically.
[MyFilter]
public class MyController : Controller {
// automatically has MyFilter logic attached to it
public ViewResult MyAction() {
}
}