Putting a common logic in every action of controll

2019-08-15 02:20发布

I am developing a mvc app where i have lot of common functionality in every controller action. My question is that where should i put a common initilization logic in every action of controller

2条回答
Rolldiameter
2楼-- · 2019-08-15 02:26

You have two choice.

  • Action Filter

  • create basecontroller and inherit all controller from basecontroller

see this link for your reference

查看更多
我只想做你的唯一
3楼-- · 2019-08-15 02:42

If you don't want to create an action filter (see here) and place the attribute in each action, you can create a controller that inherits from the base mvc controller and override the OnActionExecuting or OnActionExecuted method to provide common behavior for all actions in a controller. Hope it helps

查看更多
登录 后发表回答