【发布时间】:2011-12-21 16:05:25
【问题描述】:
我有一个自定义授权过滤器,它具有构造函数注入的依赖项。
public class CustomAuthorizationFilter : IAuthorizationFilter
还有一个只保存数据的通用属性。
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class CustomAuthorizeAttribute : FilterAttribute
我从here“借来”的一种方法,我真的很享受这种分离。我了解过滤器是如何运行并“获取”属性的,但我在接线时遗漏了一些东西。
如何将属性“绑定”到过滤器,以便在属性存在时调用过滤器? Ninject 似乎有一个syntaxforthis。但我还没有找到 Autofac 中的等价物
如果这是我需要在 Autofac 之外的应用程序中设置的东西,那也没关系。
谢谢! 乔什
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 autofac action-filter filterattribute