ASP.NET MVC: Execute code on all Actions (global OnActionExecuting?)

后端 未结 3 1636
渐次进展
渐次进展 2021-02-06 11:07

Is there a \"global\" OnActionExecuting that I can override to have all my MVC actions (regardless of controller) do something when they get called? If so, how?

3条回答
  •  情深已故
    2021-02-06 11:51

    Nope. The easiest way to do this is to write a common base class that all of your controller types subclass, then stick an action filter on that base class or override its OnActionExecuting() method.

提交回复
热议问题