title: Inject repository to custom membership provider with Ninject
body: <p>I'm trying to inject a repository to a custom membership provider with ninject in MVC 3.</p>
  
  <p>In MembershipProvider I have tried the following:</p>
  
  <pre><code>[Inject]
  public ICustomerRepository _customerRepository{ get; set; }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>[Inject]
  public TUMembershipProvider(ICustomerRepository customerRepository)
  {
      _customerRepository = customerRepository;
  }
  </code></pre>
  
  <p>In my ninject module i tried the following:</p>
  
  <pre><code>Bind&lt;MembershipProvider&gt;().ToConstant(Membership.Provider);
  </code></pre>
  
  <p>None of the above works.</p>
  
  <p>When i use(in global.asa)</p>
  
  <pre><code>kernel.Inject(Membership.Provider);
  </code></pre>
  
  <p>together with </p>
  
  <pre><code>[Inject]
  public ICustomerRepository _customerRepository{ get; set; }
  </code></pre>
  
  <p>it works, but i have no life cycle management and this will cause a "ISession is open" error from NHibernate, because the ISession is InRequestScope and the repository is not.</p>