I have added First and Last name to the ApplicationUser
Class.
public class ApplicationUser : IdentityUser
{
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
return userIdentity;
}
public string FirstName { get; set; }
public string LastName { get; set; }
}
also added information to RegisterViewModel
My application successfully created First and LastName
to the table but I am unable to get the first and last names as to display in _LoginPartial
"User.Identity.Name"
You'll need to add names as a Claim on user when user is logged in. Then in your views access these claims from
ClaimsPrincipal.Current.Claims
. Have a look on my answer here that does pretty much the same, only you need to add names instead of theme.in your partialview
_LoginPartial.cshtml
Add the code:
ApplicationDbContext
= your DBContext -> Default :ApplicationDbContext
With the instance of
ApplicationUser (user)
you can getFirst-
andLastName
-propertyReplace
User.Identity.Name
withuser.FirstName + " " + user.LastName
like this: