我认为.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?
推荐答案
首先,我需要注意ASP.NET Core(与Identity 3一起使用)不需要.NET Core。可以在.NET Core或.NET Framework 4.6.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在现有解决方案上
发布评论