Asp.net core mvc 无法创建新的索赔标识

Asp.net core mvc 无法创建新的索赔标识,asp.net-core-mvc,asp.net-identity-3,Asp.net Core Mvc,Asp.net Identity 3,我目前正试图从一个经过身份验证的用户公开一个字段,但在尝试向经过身份验证的用户添加一个新声明时遇到了一些困难 在MVC5中,我将执行以下类似操作: public class ApplicationUser : IdentityUser { public string FullName { get; set; } public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<Appl

我目前正试图从一个经过身份验证的用户公开一个字段,但在尝试向经过身份验证的用户添加一个新声明时遇到了一些困难

在MVC5中,我将执行以下类似操作:

public class ApplicationUser : IdentityUser
{
    public string FullName { get; set; }
    public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
    {
        // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
        var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
        // Add custom user claims here
        userIdentity.AddClaim(new Claim("FullName", FullName));
        return userIdentity;
    }
}
公共类应用程序用户:IdentityUser
{
公共字符串全名{get;set;}
公共异步任务GenerateUserIdentityAsync(用户管理器)
{
//注意authenticationType必须与CookieAuthenticationOptions.authenticationType中定义的类型匹配
var userIdentity=wait manager.CreateIdentityAsync(这是DefaultAuthenticationTypes.ApplicationOkie);
//在此处添加自定义用户声明
AddClaim(新声明(“全名”,全名));
返回用户身份;
}
}
然而,当我试图在MVC6中这样做时,我遇到了缺少对象和方法的问题。CreateIdentityAsync()和DefaultAuthenticationTypes似乎都丢失了,或者说visual studio是这样说的。当我深入到标识源时,我可以看到CreateIdentityAsync不再存在,但是我似乎找不到任何关于DefaultAuthenticationTypes的信息


此时此刻,我认为这是一个很好的选择,但在过去的几天里,它一直让我发疯,如果能了解出了什么问题或这是如何改变的,那就太好了。

userManager.addClaimesync(用户,新声明(“管理员”,“允许”)