加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ValidateAntiForgeryToken属性

发布时间:2020-12-16 07:35:12 所属栏目:asp.Net 来源:网络整理
导读:参见英文答案 ValidateAntiForgeryToken purpose,explanation and example????????????????????????????????????3个 有人能告诉我这个属性意味着什么.它是如何工作的? NortwhindEntities db=new NorthwindEntities();[ValidateAntiForgeryToken]public Acti
参见英文答案 > ValidateAntiForgeryToken purpose,explanation and example????????????????????????????????????3个
有人能告诉我这个属性意味着什么.它是如何工作的?

NortwhindEntities db=new NorthwindEntities();

[ValidateAntiForgeryToken]
public ActionResult Save(Product product)
{
  db.Product.Add(product);
  Return View();
}

解决方法

ValidateAntiForgeryToken属性用于防止伪造请求.需要请求验证才能保护您的MVC应用程序.
它的工作原理是在表单和cookie中添加一个新的“Anti Forgery Token”隐藏字段;然后在POST请求中验证/比较两者.
这篇文章更详细地解释了 how the anti-forgery mechanism works.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读