public ActionResult ChangePassword(ChangePasswordViewModel model) { if (model.Password != model.ConfirmPassword) { ModelState.AddModelError("", "password and Confirm password doesnot match"); return(View(model)); } UserMaster user = UserMaster.GetUserById(Convert.ToInt32(Session["uid"]), con); if (user == null) { ModelState.AddModelError("", "Invalid User or Session"); return(View(model)); } if (user.hashed_password != UserMaster.EncryptString(model.Password)) { ModelState.AddModelError("", "Invalid Old Password"); return(View(model)); } UserMaster.UpdatePassword(user.email, model.Password, con); //Write Code to send password change email return(RedirectToAction("Success", "Account", new { msg = "You have changed you password Successfully." })); }