偶尔__RequestVerificationToken错误

Mat*_*rts 9 cookies asp.net-mvc azure

我在azure上有一个MVC网络应用程序,每天有几百次,我得到了一个The required anti-forgery cookie "__RequestVerificationToken" is not present.未处理的异常日志.

我已正确设置一切,我的动作方法有[ValidateAntiForgeryToken].

我可以通过查看表单中存在令牌的异常详细信息看到,但cookie不存在.

有人知道是什么原因引起的吗?

这是完整的错误.

System.Web.Mvc.HttpAntiForgeryException (0x80004005): The required anti-forgery cookie "__RequestVerificationToken" is not present.
   at System.Web.Helpers.AntiXsrf.TokenValidator.ValidateTokens(HttpContextBase httpContext, IIdentity identity, AntiForgeryToken sessionToken, AntiForgeryToken fieldToken)
   at System.Web.Helpers.AntiXsrf.AntiForgeryWorker.Validate(HttpContextBase httpContext)
   at System.Web.Helpers.AntiForgery.Validate()
Run Code Online (Sandbox Code Playgroud)

Ond*_*dar 3

这可能是由许多问题引起的。可能导致该问题的因素:

  • 未启用 cookie 的机器人或客户端
  • 客户端上创建的 cookie 过多(每个域浏览器只能处理这么多 cookie),AntiForgeryCookie 最终被删除