Ninject with MembershipProvider | RoleProvider

Posted by DVark on Stack Overflow See other posts from Stack Overflow or by DVark
Published on 2011-01-10T18:34:25Z Indexed on 2011/01/10 18:53 UTC
Read the original article Hit count: 373

I'm using ninject as my IoC and I wrote a role provider as follows:

public class BasicRoleProvider : RoleProvider
{
    private IAuthenticationService authenticationService;

    public BasicRoleProvider(IAuthenticationService authenticationService)
    {
        if (authenticationService == null) throw new ArgumentNullException("authenticationService");
        this.authenticationService = authenticationService;
    }

    /* Other methods here */
}

I read that Provider classes get instantiated before ninject gets to inject the instance. How do I go around this? I currently have this ninject code:

Bind<RoleProvider>().To<BasicRoleProvider>().InRequestScope();

From this answer here.

If you mark your dependencies with [Inject] for your properties in your provider class, you can call kernel.Inject(MemberShip.Provider) - this will assign all dependencies to your properties.

I do not understand this.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about asp.net-mvc-3