私はasp.net MVC 5 IDフレームワークを初めて使用しています。私は自分の詳細を直接更新しようとしています。 ストレートフォワード、私がしたいのは、自分のユーザー情報をデータベースに更新することです。 以前は、マイグレーションを使用してユーザーの詳細を変更しました。エンティティフレームワークを使用してコントローラを生成し、それを表示してモデル化しました。 ただし、ユーザーの詳細を更新するにはどうすればよいですか。私はロールメソッドを見ましたが、私は理解しません、どうすればいいですか?ロールを使用せずに。 私は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 one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
である私のRegisterationモデルは
あなたApplicationUser
クラスがあなたのEntity FrameworkのDBContextの一部であり、あなたがそうのようなユーザーを検索して更新できると仮定すると
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; }
}
この[質問](http://stackoverflow.com/questions/43362226/how-to-edit-a-user-in-asp-net-identity)はあなたと似ています。 – mmushtaq
以下のリンクを参照してください。それはあなたを助けるかもしれません:http://stackoverflow.com/questions/43362226/how-to-edit-a-user-in-asp-net-identity –
あなたは私の答え@ハムンサンガをチェックしましたか? ?これはあなたが期待しているものです。 –