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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You have two choice.
Action Filter
create basecontroller and inherit all controller from basecontroller
see this link for your reference
回答2:
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