ASP.NET Core Identity 及源代码

Aspnet Core 的启动类 Startup 配置有下列代码:查看源代码  /aspnetcore

以及官方的文档解释  https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/identity?view=aspnetcore-3.1&tabs=visual-studio 

扩展方法定义:AddIdentity<TUser,TRole>(IServiceCollection)  ,  可以只有用户 AddIdentityCore<TUser>(IServiceCollection),角色另加。

                  或   AddIdentity<TUser,TRole>(IServiceCollection, Action<IdentityOptions>)   或   AddIdentityCore<TUser>(IServiceCollection, Action<IdentityOptions>)

services.AddIdentity<ApplicationUser, IdentityRole<Guid>>()
             .AddRoles<IdentityRole<Guid>>()
             .AddEntityFrameworkStores<ApplicationDbContext>()
             .AddDefaultTokenProviders();

猜你喜欢

转载自www.cnblogs.com/hopesun/p/12385958.html