📜  User.Identity.Name 用户名 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:53.796000             🧑  作者: Mango

代码示例1
public class ApplicationUser : IdentityUser
{
    public string Name { get; set; }

    public async Task GenerateUserIdentityAsync(UserManager 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("CustomName", Name));

        return userIdentity;
    }
}