ユーザーを作成しようとすると、エラーが発生します。line 15
次のコードで取得しました。
1 public async void AddOrganisationAdmin()
2 {
3
4 String OrganisationName = Request["OrganisationName"];
5 Debug.Print(OrganisationName);
6 RegisterViewModel model = new RegisterViewModel();
7 model.Email = "admin@" + OrganisationName;
8 model.Organisation = OrganisationName;
9 model.Password = "adminPassword!1";
10 model.ConfirmPassword = "adminPassword!1";
11 model.Role = "Organisation Administrator";
12
13
14 var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, Organisation = model.Organisation, Role = model.Role };
15 IdentityResult result = await UserManager.CreateAsync(user, model.Password);
16 }
エラーは次のとおりです。
An exception of type 'System.ObjectDisposedException' occurred in mscorlib.dll but
was not handled in user code
Additional information: Cannot access a disposed object.
どのオブジェクトが破棄されますか? これらの行は、asp.net mvc 5 プロジェクトのデフォルトの登録機能のコピーです。
次のような ajax 投稿から関数を呼び出しています。
$.ajax({
url: "/Account/AddOrganisationAdmin",
type: 'POST',
data: { OrganisationName : "@CompanyName"},
success: function (data, textStatus, xhr) {
console.log(data);
},
error: function (xhr, textStatus, errorThrown) {
console.log(xhr);
}
});
私は関数に入り、正しい名前を持っています。