dependency injection - ASP.NET Identity and Unity -


i using asp.net identity , unity in project implement di. there wrong signinmanager. can't use in constructor because has error. please me. usermanager , rolemanager working properly. how can use signinmanager interface.

this autherscontroller :

    private readonly usermanager<applicationuser> _usermanager;     private readonly rolemanager<identityrole> _rolemanager;     private readonly applicationsigninmanager _signinmanager;      public authorscontroller(iuserstore<applicationuser> usermanager, irolestore<identityrole, string> rolemanager, iauthenticationmanager signinmanager)     {         _usermanager = new usermanager<applicationuser>(usermanager);         _rolemanager = new rolemanager<identityrole>(rolemanager);         _signinmanager = new signinmanager<applicationsigninmanager>(signinmanager);     }      public applicationsigninmanager signinmanager     {                 {             return _signinmanager ?? httpcontext.getowincontext().get<applicationsigninmanager>();         }         private set         {             _signinmanager = value;         }     } 

and unityconfig :

        var constructor = new injectionconstructor(new applicationdbcontext());         container.registertype<iuserstore<applicationuser>, userstore<applicationuser>>(constructor);         container.registertype<irolestore<identityrole, string>, rolestore<identityrole, string, identityuserrole>>(constructor);          // todo: register types here         container.registertype<ipostsrepository, postsservice>();         container.registertype<icategoriesrepository, categoriesservice>();         container.registertype<itagsrepository, tagsservice>(); 

try this:

container.registertype<iauthenticationmanager>(new injectionfactory(c => httpcontext.current.getowincontext().authentication)); 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -