亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從身份擴展屬性的問題(ASP.NET Core)

從身份擴展屬性的問題(ASP.NET Core)

C#
元芳怎么了 2021-05-12 17:17:12
我無法從Identity擴展屬性。這樣做的全部原因是使我的員工數據庫與應用程序數據庫(包括身份信息)集成在一起,并將其用作一個大型數據庫。我嘗試遵循此答案,但似乎他們正在使用另一版本的ASP.NET。我正在使用ASP.NET Core,版本:2.0.3這是我ApplicationUser.cs文件的代碼using System;using System.Collections.Generic;using System.Linq;using System.Security.Claims;using System.Threading.Tasks;using Microsoft.AspNetCore.Identity;namespace src.Models{    public class ApplicationUser : IdentityUser    {        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) {            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);            userIdentity.AddClaim(new Claim("FirstName", this.FirstName.ToString()));            userIdentity.AddClaim(new Claim("LastName", this.LastName.ToString()));            userIdentity.AddClaim(new Claim("JobTitle", this.JobTitle.ToString()));            userIdentity.AddClaim(new Claim("Status", this.Status.ToString()));            return userIdentity;        }        string FirstName { get; set; }        string LastName { get; set; }        string JobTitle { get; set; }        string Status { get; set; }        int Age { get; set; }    }}我在出現錯誤CreateIdentityAsync,并顯示以下錯誤:'UserManager<ApplicationUser>' does not contain a definition for 'CreateIdentityAsync' and no extension method 'CreateIdentityAsync' accepting a first argument of type 'UserManager<ApplicationUser>' could be found (are you missing a using directive or an assembly reference?) [src]和上的錯誤DefaultAuthenticationTypes,錯誤:The name 'DefaultAuthenticationTypes' does not exist in the current context [src]使用ASP.NET Core無法做到這一點,還是我做錯了什么?
查看完整描述

2 回答

  • 2 回答
  • 0 關注
  • 157 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號