zl程序教程

您现在的位置是:首页 >  APP

当前栏目

如何在ASP.net MVC 5应用程序上更新我的用户帐户数据

2023-04-18 12:58:06 时间

我是新来的asp.net MVC 5身份框架,我尝试直接更新我的详细信息。直接转发,我想要做的是将我的用户信息更新到数据库。 以前,我通过使用Migrations更改了用户详细信息,并使用实体框架为了生成我的控制器,查看并自行建模。 但是,如何更新我的用户详细信息。我见过角色方法......但我从不明白,我该怎么办?没有使用角色..因为, 我想要更新UserManageController中所需的所有用户信息...如何在ASP.net MVC 5应用程序上更新我的用户帐户数据

可能吗?在不同的控制器中直接在生成的用户帐户上获取值?如何检索呢?

这里是我的身份识别模型

// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more. 
    public class ApplicationUser : IdentityUser 
    { 
     public string userFname { get; set; } 
     public string userLname { get; set; } 
     public string address { get; set; } 
     public string userContactNo { get; set; } 
     public string commercialName { get; set; } 
     public string commercialAddress { get; set; } 
     public string commercialEmail { get; set; } 
     public string userType { get; set; } 

     public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) 
     { 
      // Note the authenticationType must match the>public class RegisterViewModel 
{ 
    [Required] 
    [Display(Name = "User First Name")] 
    public string userFname { get; set; } 

    [Required] 
    [Display(Name = "User Last Name")] 
    public string userLname { get; set; } 

    [Required] 
    [Display(Name = "User Address")] 
    public string address { get; set; } 

    [Required] 
    [Display(Name = "User Contact Number")] 
    public string userContactNo { get; set; } 

    [Display(Name = "Commercial Name")] 
    public string commercialName { get; set; } 

    [Display(Name = "Commercial Address")] 
    public string commercialAddress { get; set; } 

    [EmailAddress] 
    [Display(Name = "Commercial Email")] 
    public string commercialEmail { get; set; } 

    [Key] 
    [Required] 
    [EmailAddress] 
    [Display(Name = "Email")] 
    public string Email { get; set; } 

    [Required] 
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] 
    [DataType(DataType.Password)] 
    [Display(Name = "Password")] 
    public string Password { get; set; } 

    [DataType(DataType.Password)] 
    [Display(Name = "Confirm password")] 
    [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] 
    public string ConfirmPassword { get; set; } 

    [Required]   
    public string userType { get; set; } 

} 

Hamun Sunga

This [question](http://stackoverflow.com/questions/43362226/how-to-edit-a-user-in-asp-net-identity)看起来与你的相似。 –

请访问下面的链接,它可能会帮助你:http://stackoverflow.com/questions/43362226/how-to-edit-a-user-in-asp-net-identity –

你检查我的答案@HamunSunga? ?这是你期待的。 –

回答

如何在ASP.net MVC 5应用程序上更新我的用户帐户数据