gpt4 book ai didi

asp.net-mvc - ValidateAntiForgeryToken 属性

转载 作者:行者123 更新时间:2023-12-03 18:26:14 27 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





ValidateAntiForgeryToken purpose, explanation and example

(4 个回答)


7年前关闭。




谁能告诉我那个属性是什么意思。它是如何工作的?

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 .

关于asp.net-mvc - ValidateAntiForgeryToken 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19429561/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com