Using Ninject with Membership.Provider

前端 未结 4 1095
刺人心
刺人心 2021-01-11 14:19

I\'m new to Ninject and I\'m having problems using it with a custom membership provider.

My membership provider has a repository interface passed in. It looks like:<

4条回答
  •  太阳男子
    2021-01-11 14:51

    This is how it should be done today with new versions of both MVC and Ninject (version 3):

    You have access to the DependencyResolver instance and Ninject sets itself as the current DependencyResolver. That way you don't need hacks to get access to the static Ninject kernel. Please note, my example uses my own IUserService repository for Membership...

    IUserService _userService = DependencyResolver.Current.GetService();
    

提交回复
热议问题