MVC5 BindAttribute// POST: Movies/Create// 为了防止“过多发布”攻击,请启用要绑定到的特定属性,有关 // 详细信息,请参阅 http://go.microsoft.com/fwlink/?Link ...
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);
}
其中[Bind(Include="ID,Title,ReleaseDate,Genre,Price")]
The Bind attribute is another important security mechanism that keeps hackers from over-posting data to your model.
大意是:BindAttribute 是一个防止黑客“OverPost”攻击的重要安全机制。
来自为知笔记(Wiz)
原标题:MVC5学习笔记 BindAttribute
关键词:mvc
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。