asp.net mvc - How do I inject Identity classes with Ninject? -


i'm trying use usermanager in class, i'm getting error:

error activating iuserstore{applicationuser} no matching bindings available, , type not self-bindable. 

i'm using default startup.cs, sets single instance per request:

app.createperowincontext(applicationdbcontext.create); app.createperowincontext<applicationusermanager>(applicationusermanager.create); 

i'm able applicationdbcontext instance, believe getting injected owin (is true?):

public class genericrepository<t> : igenericrepository<t> t : class {     private applicationdbcontext context;      public genericrepository(applicationdbcontext context)     {         this.context = context;     } } 

but can't same usermanager (it throws error shown before):

public class anunciosservice : ianunciosservice {     private igenericrepository<anuncio> _repo;     private applicationusermanager _usermanager;      public anunciosservice(irepositoriogenerico<anuncio> repo, applicationusermanager usermanager)     {         _repo = repo;         _usermanager = usermanager;     } } 

the controller uses usermanager this:

public applicationusermanager usermanager     {                 {             return _usermanager ?? httpcontext.getowincontext().getusermanager<applicationusermanager>();         }         private set         {             _usermanager = value;         }     } 

i'm using ninject inject other classes, how inject usermanager it's dependencies , avoid using in controllers?

i injected this

kernel.bind<iuserstore<applicationuser>>().to<userstore<applicationuser>>(); kernel.bind<usermanager<applicationuser>>().toself(); 

and it's working should.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -