public async Task <IActionResult> OnPostChangeEmailAsync() { var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } if (!ModelState.IsValid) { await LoadAsync(user); return(Page()); } var email = await _userManager.GetEmailAsync(user); if (Input.NewEmail != email) { var changeEmailLink = await LinkBuilder.GetChangeEmailLink(_userManager, user, Input.NewEmail, Request); await _emailSendingService.SendChangeEmail(user, changeEmailLink); StatusMessage = "Confirmation link to change email sent. Please check your email."; return(RedirectToPage()); } StatusMessage = "Your email is unchanged."; return(RedirectToPage()); }