public async Task <IActionResult> ForgetPassword(ForgetPasswordViewModel model) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Profile")); } UserModel user = await ManageUser.FindByEmailAsync(model.Email); ViewBag.Sent = false; if (user != null) { var token = await ManageUser.GeneratePasswordResetTokenAsync(user); var callbackUrl = Url.Action("ResetPassword", "Account", new { token = token, email = user.Email }); var url = "https://" + Request.Host + callbackUrl; MailRequest mailrequest = new MailRequest { ToEmail = model.Email, Subject = "Password Reset Token", Body = "<div style='text-align:center'> <h1 style='margin:20px;'> Reset Your Password. </h1> <a href='" + url + "' > Reset Password </a> </div>" }; var result = await SendToken(mailrequest); if (result) { ViewBag.Sent = true; } } return(View()); }