//Method to change password if forget password. public ActionResult SaveForgetPassword(IFormCollection frm) { string email = frm["EmailId"]; int? userId = _repObj.ValidateEmailId(email); if (userId != null) { HttpContext.Session.SetString("EmailForForgot", email); DateTime expires = DateTime.Now + TimeSpan.FromMinutes(4); string hash = MakeExpiryHash(expires); string link = string.Format("https://localhost:44320/Login/ChangePassword?exp={0}&k={1}", userId + expires.ToString("s"), hash); _repObj.sendEMailThroughOUTLOOK(email, link); return(RedirectToAction("Index")); } else { TempData["msg"] = "Invalid Email ID."; return(RedirectToAction("ForgotPassword")); } }