How to register custom UserStore & UserManager in DI

后端 未结 3 1498
-上瘾入骨i
-上瘾入骨i 2020-12-28 19:01

Here is my setup:

public class ApplicationUser : IdentityUser
{
}
public class ApplicationRole : IdentityRole
{
}
public class Applic         


        
3条回答
  •  时光说笑
    2020-12-28 19:10

    I came up with this:

    // Extract IApplicationUserManager interface with all methods you are using
    public class ApplicationUserManager : UserManager, IApplicationUserManager
    
    // Register your custom user manager
    services.AddIdentity()
        .AddUserManager();
    
    // Return same scoped instance whenever you injecting your custom user manager into any constructor
    services.AddScoped(s => s.GetService());
    

提交回复
热议问题