Answers for "User.Identity.Name username"

0

User.Identity.Name username

public class ApplicationUser : IdentityUser
{
    public string Name { 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("CustomName", Name));

        return userIdentity;
    }
}
Posted by: Guest on December-23-2020

Browse Popular Code Answers by Language