开发者

ASP.NET MVC ActionFilter Analog for whole controller

开发者 https://www.devze.com 2022-12-25 02:40 出处:网络
Is it possible to inject behavior for whole controller, like it could be d开发者_开发问答one for action with ActionFilterAttribute

Is it possible to inject behavior for whole controller, like it could be d开发者_开发问答one for action with ActionFilterAttribute

Best regards, Alexey Zakarov


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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消