MVC5 Study Notes Bindattribute

Source: Internet
Author: User

MVC5 Bindattribute
  1. // POST: Movies/Create
  2. // 为了防止“过多发布”攻击,请启用要绑定到的特定属性,有关
  3. // 详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkId=317598。
  4. [HttpPost]
  5. [ValidateAntiForgeryToken]
  6. publicActionResultCreate([Bind(Include="ID,Title,ReleaseDate,Genre,Price")]Movie movie)
  7. {
  8. if(ModelState.IsValid)
  9. {
  10. db.Movies.Add(movie);
  11. db.SaveChanges();
  12. returnRedirectToAction("Index");
  13. }
  14. returnView(movie);
  15. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.