public async Task <IActionResult> OnPostAsync() { try { if (ModelState.IsValid) { User user = await _userManager.FindByEmailAsync(ForgotPasswordViewModel.Email); if (user != null && (await _userManager.IsEmailConfirmedAsync(user))) { string resetPasswordToken = await _userManager.GeneratePasswordResetTokenAsync(user); string resetPasswordCallbackLink = Url.Page("/Account/ResetPasswordConfirmation", pageHandler: "ResetPassword", new { UserId = user.Id, Token = resetPasswordToken }, protocol: HttpContext.Request.Scheme); await _resetPasswordService.SendResetPasswordConfirmationLinkToEmailAsync(user, resetPasswordCallbackLink); return(RedirectToPagePermanent("Info", "GetInfoMessage", new { message = "Ссылка на восстановление пароля выслана на вашу почту: " + user.Email })); } else { ModelState.AddModelError(string.Empty, "Неверный Email или он не подтверждён"); } } else { ModelState.AddModelError(string.Empty, "Неверный Email"); } return(Page()); } catch (Exception e) { _logger.LogError(e, "Error while interaction on ForgotPasswordPage"); return(NotFound()); } }