gpt4 book ai didi

asp.net-mvc - 防伪异常 : A required anti-forgery token was not supplied or was invalid

转载 作者:行者123 更新时间:2023-12-01 05:39:07 25 4
gpt4 key购买 nike

我有一个 MVC2 应用程序。我正在尝试实现 AntiForgeryToken 帮助程序来防止 CSRF 攻击。

我正在使用 Steve Sanderson 的博客实现这一点:http://blog.stevensanderson.com/2008/09/01/prevent-cross-site-request-forgery-csrf-using-aspnet-mvcs-antiforgerytoken-helper/

当我在新的 MVC2 项目中实现它时,它可以工作。但是当我把它放在我的真实应用程序中时,它总是抛出这个异常:
所需的防伪 token 未提供或无效。

这是我的 Controller 代码:

[ValidateAntiForgeryToken]
public ActionResult SubmitUpdate()
{

// Something goes here
return View();
}

View 中的代码:
<% using (Html.BeginForm("SubmitUpdate", "Test"))
{%>
<%= Html.AntiForgeryToken() %>
<input type="submit" value="Submit" />
<% } %>

除了实际应用使用 ADFS 进行身份验证外,这两个应用没有任何区别。我错过了什么?任何帮助将不胜感激。谢谢!

最佳答案

您是否尝试删除 cookie 并重试?

关于asp.net-mvc - 防伪异常 : A required anti-forgery token was not supplied or was invalid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6792435/

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