How can you inject an asp.net (mvc2) custom membership provider using Ninject?

Posted by AlDev on Stack Overflow See other posts from Stack Overflow or by AlDev
Published on 2010-06-03T05:58:58Z Indexed on 2010/06/03 6:04 UTC
Read the original article Hit count: 781

OK, so I've been working on this for hours. I've found a couple of posts here, but nothing that actually resolves the problem. So, let me try it again...

I have an MVC2 app using Ninject and a custom membership provider.

If I try and inject the provider using the ctor, I get an error: 'No parameterless constructor defined for this object.'

public class MyMembershipProvider : MembershipProvider
{
    IMyRepository _repository;

    public MyMembershipProvider(IMyRepository repository)
    {
        _repository = repository;
    }

I've also been playing around with factories and Initialize(), but everything is coming up blanks.

Any thoughts/examples?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about ninject