ASPNET Identity Caching with Dependency Injection

纵然是瞬间 提交于 2019-12-12 06:22:21

问题


I am using Ninject in an MVC application with ASPNET Identity 2.

Log in, log out, updating password etc are all working fine. However if I update the user's name in the database, the ApplicationUserManager seems to be caching the user information.

This is the code to register the Identity services:

private void RegisterServices()
{
    kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

    var dbContext = kernel.Get<ApplicationDbContext>();
    kernel.Bind<IUserStore<ApplicationUser>>().To<UserStore<ApplicationUser>>().WithConstructorArgument("context", dbContext);

    kernel.Bind<IAuthenticationManager>().ToMethod(x => HttpContext.Current.GetOwinContext().Authentication);
}

I have posted a sample solution on GitHub. WebApplication1 works without DI, and WebApplication2 with Ninject shows the caching behaviour.

Any advice on using ASPNET identity with DI would be appreciated.

来源:https://stackoverflow.com/questions/29170366/aspnet-identity-caching-with-dependency-injection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!