Configure Unity DI for ASP.NET Identity

后端 未结 4 763
花落未央
花落未央 2020-12-01 13:08

I\'m using Unity successfully for all regular constructor injection such as repositories etc., but I can\'t get it working with the ASP.NET Identity classes. The setup is th

4条回答
  •  青春惊慌失措
    2020-12-01 13:27

    Install-Package Unity.AspNet.WebApi
    

    You need to register Unity under the HttpConfiguration.DependencyResolver property. This allows WebApi to know that it needs to use Unity rather than reflection to instanciate your controllers.

    The easiest way to do this is with the above nuget package.

提交回复
热议问题