public ActionResult Forgot(User user) { if (String.IsNullOrEmpty(user.UserName)) { ModelState.AddModelError("", "Please fill the Username field"); return(View(user)); } var uFound = db.Users.ToList().FirstOrDefault(x => x.UserName.Equals(user.UserName)); if (uFound != null) { var err = EmailClient.SendEmailFromWebMaster(uFound.Email, uFound.Name + ", your password is: " + uFound.Password, "Password Recovery"); if (err == null) { user.Email = uFound.Email; } ModelState.AddModelError("", err); } else { ModelState.AddModelError("", String.Format("Username '{0}' not found in our database", user.UserName)); } return(View(user)); }