[HttpPost] public ActionResult Create(Users user) { ModelState.Remove(“Password”); //加上这句就行了 if (ModelState.IsValid) { user.Password="admin"; db.Users.Add(user); db.SaveChanges(); return View("Index"); } return View(); }
时间: 2024-10-10 18:29:53
[HttpPost] public ActionResult Create(Users user) { ModelState.Remove(“Password”); //加上这句就行了 if (ModelState.IsValid) { user.Password="admin"; db.Users.Add(user); db.SaveChanges(); return View("Index"); } return View(); }