简体   繁体   English

是否可以将ASP.NET Core身份添加到WebForms项目中?

[英]Is it possible to add ASP.NET Core Identity to a WebForms project?

I know it is possible to add ASP.NET Identity (note NOT Core) to a WebForms project. 我知道可以 ASP.NET标识(​​注意不是Core)添加到WebForms项目中。 But what I want to do is add ASP.NET Core Identity to an existing WebForms project. 但是我要做的是将ASP.NET Core Identity添加到现有的WebForms项目中。

  1. Is this possible? 这可能吗?
  2. If 1. is not possible, then how do I share an ASP.NET Core Identity user database between my .NET Core application and WebForms application so that I can implement https://docs.microsoft.com/en-us/aspnet/core/security/cookie-sharing?view=aspnetcore-2.2#use-a-common-user-database 如果1.不可能,那么如何在.NET Core应用程序和WebForms应用程序之间共享ASP.NET Core Identity用户数据库,以便可以实现https://docs.microsoft.com/zh-cn/aspnet/核心/安全性/ Cookie共享?view = aspnetcore-2.2#use-a-common-user-database

It is definitely possible to share the database 绝对有可能共享数据库

Option 1 : you will need to do some custom implementation since Core Identity (v3) might have a slightly different schema than .NET Framework Identity (v2). 选项1 :您将需要执行一些自定义实现,因为Core Identity(v3)的架构可能与.NET Framework Identity(v2)略有不同。 Take a look at the following link https://docs.microsoft.com/en-us/aspnet/identity/overview/extensibility/index 看一下以下链接https://docs.microsoft.com/zh-cn/aspnet/identity/overview/extensibility/index

You might need to also override the PasswordHasher if they are different implementations. 如果它们是不同的实现,则可能还需要覆盖PasswordHasher。 Check the following article out: https://andrewlock.net/exploring-the-asp-net-core-identity-passwordhasher/ 请查看以下文章: https : //andrewlock.net/exploring-the-asp-net-core-identity-passwordhasher/

Option 2 : You can expose login/registering/membership functionality from your Core project and consume from your WebForm as a rest service. 选项2 :您可以从Core项目中公开登录/注册/会员功能,并从WebForm中将其用作休息服务。 There are several rest security schemes and middleware. 有几种其他的安全方案和中间件。

See: 看到:

Those are a few quick ones. 这些是一些快速的。 You can probably extrapolate and get some other ideas from looking at the source for Identity lib ( https://github.com/aspnet/AspNetCore/tree/master/src/Identity ) If you scroll down the readme you'll see different Store providers. 您可以通过查看Identity lib( https://github.com/aspnet/AspNetCore/tree/master/src/Identity )的源来推断并获得其他一些想法。如果向下滚动自述文件,则会看到不同的Store提供者。 For Option 1 you would need to essentially write a Core Store for your Web Forms Identity lib ( https://archive.codeplex.com/?p=aspnetwebstack ) 对于选项1,您实际上需要为Web窗体身份库( https://archive.codeplex.com/?p=aspnetwebstack )编写一个核心存储。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM