ASP.NET MVC:执行的所有操作code(全球OnActionExecuting?) [英] ASP.NET MVC: Execute code on all Actions (global OnActionExecuting?)

查看:78
本文介绍了ASP.NET MVC:执行的所有操作code(全球OnActionExecuting?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个全球性OnActionExecuting,我可以覆盖有所有的我的MVC的行为(无论控制器)做一些事情,当他们被调用?如果是这样,怎么样?

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?

推荐答案

不。要做到这一点最简单的方法是写一个共同的基类,所有控制器类型的子类的,然后坚持一个动作过滤器的基类或覆盖其OnActionExecuting()方法。

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.

这篇关于ASP.NET MVC:执行的所有操作code(全球OnActionExecuting?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆