我正在使用.NET Core 2 Razor Pages和個人帳戶身份驗證來開發(fā)Web應(yīng)用程序。我用名字擴展數(shù)據(jù)庫,因為它不是標(biāo)準(zhǔn)實現(xiàn)的。一切正常。但是,我想擴展我的/ Account / Manage頁面,以確保用戶能夠更改自己的名稱。OnGetAsync可以正常工作,但是當(dāng)我的OnPostAsync無法正常工作時。OnPostAsync public async Task<IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return Page(); } var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } if (Input.Email != user.Email) { var setEmailResult = await _userManager.SetEmailAsync(user, Input.Email); if (!setEmailResult.Succeeded) { throw new ApplicationException($"Unexpected error occurred setting email for user with ID '{user.Id}'."); } } if (Input.PhoneNumber != user.PhoneNumber) { var setPhoneResult = await _userManager.SetPhoneNumberAsync(user, Input.PhoneNumber); if (!setPhoneResult.Succeeded) { throw new ApplicationException($"Unexpected error occurred setting phone number for user with ID '{user.Id}'."); } } // not working yet if (Input.FirstName != user.FirstName) { var setFirstNameResult = await MyManager.SetFirstNameAsync(user, Input.FirstName); if (!setFirstNameResult.Succeeded) { throw new ApplicationException($"Unexpected error occurred setting first name for user with ID '{user.Id}'."); } } StatusMessage = "Your profile has been updated"; return RedirectToPage(); }當(dāng)我點擊“保存”按鈕并告訴我我的個人資料已成功更新時,它失敗了,但是沒有成功。它只是保留了舊的名字值。我在這里想念什么?
- 1 回答
- 0 關(guān)注
- 154 瀏覽
添加回答
舉報
0/150
提交
取消