[英]How to disable global attribute for a specific action\controller in MVC4
Ive got an attribute registered in global filters. 我已经在全局过滤器中注册了一个属性。 And I want it to be disabled for 2 actions.
我希望它能够在2个动作中被禁用。 How can I do this?
我怎样才能做到这一点?
There are a couple of ways to handle this: 有几种方法可以解决这个问题:
IFilterProvider
interface and inside the GetFilters
method that you're gonna need to implement test whether the controller action is decorated with some custom marker attribute and not include your global filter in the result. IFilterProvider
接口编写自定义过滤器提供程序,并在GetFilters
方法内部,您需要实现测试控制器操作是否使用某些自定义标记属性进行修饰不在结果中包含全局过滤器。 Then do not register the filter as a global action filter but register your custom filter provider instead. an article
which illustrates that in details with StructureMap. an article
用StructureMap详细说明an article
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.