ASP.NET MVC 3, Action Filters, and Autofac Dependency Injection

前端 未结 2 1023
一整个雨季
一整个雨季 2021-01-02 17:02

On ASP.NET MVC 2 I have an ActionFilterAttribute called [Transaction] that starts an NHibernate transaction before executing the a

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-02 17:53

    I just asked a similar question on google forums. Here is the link https://groups.google.com/forum/#!topic/autofac/a0qqp2b3WA8

    I got the answer:

    builder.RegisterType().As();
    
    
    builder.RegisterControllers(Assembly.GetExecutingAssembly()).InjectActionInvoker();
    

    Then you can use property injection in your attributes.

提交回复
热议问题