我只是看着我的一些旧代码,我有一个动作过滤器(OnActionExecuting方法)
和在它的结尾我有
base.OnActionExecuting(filterContext);
解决方法
Should I be always be calling the base methods after?
这将取决于情况。
例如,在授权过滤器(从AuthorizeAttribute派生)中,如果调用基本方法,则将会执行内置到ASP.NET MVC中的所有现有授权逻辑。如果你不调用它,只有你的授权逻辑将被应用。
就其他标准动作过滤器(从ActionFilterattribute派生),所有的OnActionExecuting,OnActionExecuted,OnResultExecuting和OnResultExecuted被定义为virtual,但它们的主体是空的,所以如果你调用或不是基础方法,它没有任何区别。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。