Autofac and ASP.NET Web API ApiController

前端 未结 2 918
悲&欢浪女
悲&欢浪女 2021-02-08 15:57

I have been using autofac with MVC 3 for a while and love it. I recently upgraded a project to MVC 4 and everything seems to be working except for Web Api ApiControllers. I am g

2条回答
  •  遇见更好的自我
    2021-02-08 17:03

    I have released Autofac integration packages on NuGet for the Beta versions of MVC 4 and Web API. The integrations will create an Autofac lifetime scope per controller request (MVC controller or API controller depending on the integration). This means that the controller and its dependencies will be automatically disposed at the end of each call. Both packages can be installed side-by-side in the same project.

    MVC 4

    https://nuget.org/packages/Autofac.Mvc4

    http://alexmg.com/post/2012/03/09/Autofac-ASPNET-MVC-4-(Beta)-Integration.aspx

    Web API

    https://nuget.org/packages/Autofac.WebApi/

    http://alexmg.com/post/2012/03/09/Autofac-ASPNET-Web-API-(Beta)-Integration.aspx

    Links are now fixed.

提交回复
热议问题