2
我在嘗試創建用戶時遇到錯誤。我在下面的代碼中通過line 15
得到它。ObjectDisposedException在創建用戶時
1 public async void AddOrganisationAdmin()
2 {
3
4 String OrganisationName = Request["OrganisationName"];
5 Debug.Print(OrganisationName);
6 RegisterViewModel model = new RegisterViewModel();
7 model.Email = "[email protected]" + 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);
}
});
我進入功能和我有正確的名稱。
你有你自己的'IDisposable'或finalizier的實現嗎? –
@AmitKumarGhosh不,我沒有自己的實現。 –
你能展示''CreateAsync'方法嗎? –