how to set user.identity.name code example

Example: User.Identity.Name username

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;
    }
}

Tags:

Misc Example