简体   繁体   English

FilterAttribute顺序不起作用

[英]FilterAttribute Order not working

I have 2 attributes that I use within the controllers of my MVC application. 我在MVC应用程序的控制器中使用2个属性。 AttributeA extends System.Web.Mvc.AuthorizeAttribute and AttributeB extends System.Web.Mvc.ActionFilterAttribute . AttributeA扩展了System.Web.Mvc.AuthorizeAttribute,而AttributeB扩展了System.Web.Mvc.ActionFilterAttribute I want AttributeB to always be run first. 我希望AttributeB始终先运行。

I have tried all possible combinations of Order based on this article , but AttributeA is always run before AttributeB. 我已经根据本文尝试了Order的所有可能组合,但是AttributeA 始终在AttributeB之前运行。 Can anyone help? 有人可以帮忙吗?

如果查看带有反射器的System.Web.Mvc.ControllerActionInvoker.InvokeAction方法,您会看到所有实现IAuthorizationFilter的过滤器在从ActionFilterAttribute派生的属性之前都被调用,这是因为在进行该操作之前已进行了授权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 自定义FilterAttribute中的Order参数是什么 - What is the Order argument in custom FilterAttribute 为方法参数创建自定义FilterAttribute - Creating custom FilterAttribute for method parameters Autofac注入到自定义Web-Api FilterAttribute - Autofac injection to custom Web-Api FilterAttribute 自定义操作过滤器应该继承FilterAttribute吗? - should custom action filter inherit FilterAttribute? 在BaseController的OnActionExecuting之前调用FilterAttribute的OnActionExecuting - Calling FilterAttribute's OnActionExecuting before BaseController's OnActionExecuting ASP.NET MVC 3:是否可以将模型绑定对象传递给FilterAttribute? - ASP.NET MVC 3: Can I pass a modelbound object to a FilterAttribute? 如何从FilterAttribute中获取当前Url? - How do I get the current Url from within a FilterAttribute? 是否可以在ASP.NET MVC FilterAttribute上使用依赖注入/ IoC? - Is it possible to use Dependency Injection/IoC on an ASP.NET MVC FilterAttribute? ASP.NET MVC 6 中 FilterAttribute 内的依赖注入 - Dependency injection inside a FilterAttribute in ASP.NET MVC 6 nhibernate中的按日期排序列按字母顺序排列 - Order by date column in nhibernate is working as order by string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM