首页 > 解决方案 > 在 AspnetCore AspIdentity 上重用的 Aspidentity 2.2(框架 4.x)

问题描述

现有:aspnet webapp 和 dB,使用 aspidentity 在控制器上 [Authorize]

新:AspnetCore 应用程序,如何使用“旧”的 aspidentity DB 进行授权?

标签: asp.net.net-core

解决方案


AspNet 解决方案:

  1. 数据库更新:https ://github.com/CK159/CoreXplore/tree/master/Db/Migrations/Identity2Core

  2. 为新列添加迁移。

  3. 更新新的 AspNetUsers ApplicationUser 类属性: ConcurrencyStamp = System.Guid.New(); NormalizedEmail = Email.Upper(); NormalizedUserName = Email.Upper();
  4. 使用新属性和默认值更新新的 ApplicationUser

AspNetCore 解决方案:

  1. 在兼容模式下配置 aspnetcore PasswordHasher 使用 V2 选项。V3登录AspNetCore解决方案,用户无法登录AspNet解决方案:byservices.Configure<PasswordHasherOptions>(o => o.CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2);
  2. 连接字符串指向现有数据库
  3. 部署在与退出 Azure 上的 WebApp 相同的 WebApp“主机”中,这样​​它将共享相同的机器密钥(不完全确定这是必要的)。

推荐阅读