首页 > Web开发 > 详细

ASP.NET Core Identity 及源代码

时间:2020-02-29 21:15:34      阅读:191      评论:0      收藏:0      [点我收藏+]

 

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>)

 

// AddIdentity 源代码: https://github.com/dotnet/aspnetcore/blob/v3.1.2/src/Identity/Extensions.Core/src/IdentityServiceCollectionExtensions.cs

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

 

ASP.NET Core Identity 及源代码

原文:https://www.cnblogs.com/hopesun/p/12385958.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!