MVC5 Bindattribute
// POST: Movies/Create
// 为了防止“过多发布”攻击,请启用要绑定到的特定属性,有关
// 详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=317598。
[HttpPost]
[ValidateAntiForgeryToken]
publicActionResultCreate([Bind(Include="ID,Title,ReleaseDate,Genre,Price")]Movie movie)
{
if(ModelState.IsValid)
{
db.Movies.Add(movie);
db.SaveChanges();
returnRedirectToAction("Index");
}
returnView(movie);
}
Where [Bind(Include="ID,Title,ReleaseDate,Genre,Price")] the Bind attribute is another important security mechanism, keeps hackers from over-posting data to yo ur model.
The main idea is: Bindattribute is an important security mechanism to prevent hackers from "overpost" attacks.
"Overpost": in fact, when using the form submission tool to simulate the submission, manually add some strange things. When the Form is post, Requestbody is id=1&title=123&releasedate=20150502&genre=science&price=10&HHH= Test. "Hhh=test" is "over-posting". Detailed View: Over Posting note
From for notes (Wiz)
MVC5 Study Notes Bindattribute