.Net Identity 3在现有解决方案上 [英] .Net Identity 3 on existing solution

查看:93
本文介绍了.Net Identity 3在现有解决方案上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为.NET Identity 3无法在现有(v4.5)ASP.NET解决方案上运行,但需要.NET Core。我无法更新到.NET Core。有没有解决方法?如果不是,那么人们应该如何从ASP.NET成员身份迁移到ASP.Net Identity?

I believe that .NET Identity 3 cannot run on an existing (v4.5) ASP.NET solution, but requires .NET Core. I cannot update to .NET Core. Is there a workaround for this? If not then how are people supposed to migrate from ASP.NET Membership to ASP.Net Identity?

推荐答案


  1. 首先,我需要注意ASP.NET Core(与Identity 3一起使用)不需要.NET Core。可以在.NET Core或.NET Framework 4.6.1(或更高版本)上使用它。

  1. First of all, I need to note that ASP.NET Core (which works with Identity 3) does not require .NET Core. It can be used either over .NET Core or .NET Framework 4.6.1 (or higher).

我想您在两种情况下都使用默认方法(成员身份和身份),有关用户,角色,密码等的所有信息都存储在某个数据库中。

I guess you use the default approach in both cases (Membership and Identity) when all information about users, roles, passwords, etc, is stored in some database.

,从成员身份迁移到身份的最佳方法如下:

So, the best way to migrate from Membership to Identity is the following:


  • 使用默认模板并使用创建新的ASP.NET Core项目。打开身份验证

  • 然后编写一个小型控制台程序,该程序会将所有与用户相关的信息从您的旧成员资格表移至新成员资格表(由ASP.NET Identity自动创建)
  • 然后依次移动所有其他控制器和视图。

唯一的问题-是身份将无法识别通过成员身份创建的密码散列。要解决该问题,您需要定义自己的IPasswordHasher接口实现,并按照这篇文章

The only problem here - is that Identity will not recognize the passwords' hashes created with Membership. To resolve it you will need to define your own implementation of IPasswordHasher interface and register it in DI container as it's described in this article.

这篇关于.Net Identity 3在现有解决方案上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆