Мой текущий код в следующем.Как получить и установить пользовательскую информацию в mvc 5 Identity?
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 class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
Я хочу, чтобы добавить сумму более свойств в классе ApplicationUser так, что эти поля, доступные на представлениях, как
@User.Identity.FullName
Моя Войти действие размещенные на here
Вы не можете продлить этот класс, но вы можете получить экземпляр 'ApplicationUser' (где вы можете добавить свои собственные свойства). Для простой аутентификации это примерно так: 'UserManager.FindById (User.Identity.GetUserId());' –
возможно [это] (http://stackoverflow.com/questions/38846816/how-to-get-custom-property- значение-of-the-applicationuser-in-the-asp-net-mvc-5-vie/38847016 # 38847016) поможет – tmg
@AdrianoRepetti, пожалуйста, проверьте http://stackoverflow.com/questions/28335353/how-to-extend -доступные-свойства-пользователя-идентификатора – Bharat