Asp.net mvc 3 使用Autofac进行属性注入

Asp.net mvc 3 使用Autofac进行属性注入,asp.net-mvc-3,autofac,property-injection,Asp.net Mvc 3,Autofac,Property Injection,所以我有一个简单的问题(我想) 如何使用Autofac对FilterAttribute进行属性注入 Public Class TestFilterAttribute Inherits ActionFilterAttribute Public Property Service As IMyService Public Overrides Sub OnActionExecuting(filterContext As System.Web.Mvc.Actio

所以我有一个简单的问题(我想)

如何使用Autofac对FilterAttribute进行属性注入

Public Class TestFilterAttribute
    Inherits ActionFilterAttribute

    Public Property Service As IMyService        

    Public Overrides Sub OnActionExecuting(filterContext As System.Web.Mvc.ActionExecutingContext)

        ** I need to get to the IMyService here **
        Dim val = Service.GetValue()

        MyBase.OnActionExecuting(filterContext)
    End Sub
End Class
我已在容器中注册服务:

builder.RegisterType(Of MyService).As(Of IMyService)().InstancePerHttpRequest()
也许我走错了方向。我希望能够注入过滤器属性


另外,在使用
寄存器时,是否也必须执行
?与在
RegisterType

中一样,请确保在容器生成器上调用RegisterFilterProvider方法,它将处理其余部分