private string attrNames= "ID,Title,ReleaseDate,Genre,Price";
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = attrNames)] Movies movies)
{
if (ModelState.IsValid)
{
db.Entry(movies).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(movies);
}
为什么应该将attrNames声明为静态?这是正确的使用方法,只是试验
* .Net MVC 5新手