【问题标题】:Extending IdentityUser in Asp.Net Core Identity 2.0 when it's a NuGet package当它是 NuGet 包时,在 Asp.Net Core Identity 2.0 中扩展 IdentityUser
【发布时间】:2019-07-24 13:27:11
【问题描述】:

在这篇博客ASP.NET Core 2.1.0-preview1: Introducing Identity UI as a library 中,我发现 ASP.Net Core 2.0 中的身份概念正在作为 NuGet 包提供。

我正在做一个项目,我需要将包含的 IdentityUser 扩展为多个一对多关系。

我想将属性添加到我的用户类中,例如 List 和 List。

使用 NuGet 包中的 IdentityUser,人们如何自定义它?如果每个人都想自定义 NuGet 包,他们会选择退出吗?

【问题讨论】:

  • 看不到在您想要自定义 NuGet 时如何选择退出。我觉得你在这里误解了一些概念。您在使用 NuGet 进行此自定义时是否遇到任何困难?
  • 不确定这是否是您要查找的内容,但IdentityUser 等类可以在Microsoft.Extensions.Identity.Stores NuGet 包中找到

标签: c# asp.net-core asp.net-identity asp.net-identity-2


【解决方案1】:

该博客专门讨论 UI 元素,而您似乎在询问后端代码...

如果你只是想在 User 模型中添加一些自定义的东西,这已经被支持了: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/customize-identity-model?view=aspnetcore-2.2

基本上,您可以创建一个派生自(继承自)IdentityUser 的自定义类,向其添加自定义属性,然后在设置身份时您可以使用它而不是股票 IdentityUser。

【讨论】:

    猜你喜欢
    • 2014-12-14
    • 1970-01-01
    • 2019-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-16
    • 2016-08-17
    • 2020-03-31
    相关资源
    最近更新 更多