【问题标题】:Application pool crashing after the exception, The anti-forgery cookie token and form field token do not match异常后应用程序池崩溃,防伪cookie令牌和表单字段令牌不匹配
【发布时间】:2016-10-11 12:06:22
【问题描述】:

我有 MVC 4 应用程序,其应用程序池不时停止。我在事件查看器 Windows 应用程序日志中看到此异常Exception information: Exception type: HttpAntiForgeryException Exception message: The anti-forgery cookie token and form field token do not match. .....................

我的控制器操作具有如下所示的 ValidateAntiForgeryToken 设置

  [HttpPost]
  [ValidateAntiForgeryToken]
  [OutputCache(Duration = 0)]
  public ActionResult Login(LoginViewModel model, string returnUrl, bool loginbutton = true)
    {
    ///
    }

在我的视图中我确实有

 @using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", @id = "login-form" }))
        {
            @Html.AntiForgeryToken()
             ....................
        }

我查看了这个question 并添加了机器密钥,但这也无济于事。任何想法为什么会发生这种情况?该网站正在使用 SSL 证书,但我认为这不会导致任何问题。

【问题讨论】:

  • 您会不时将此消息视为正常的事件过程。如果用户做了一些事情,比如离开表单一段时间然后再提交,那么令牌将是无效的。无论如何,这不会导致整个 App Pool 崩溃。这将需要内存泄漏或其他更严重的问题。
  • 我刚刚设置了调试诊断故障转储,可能会发现更多信息。还有什么我们可以尝试找出实际问题的方法吗?

标签: asp.net-mvc cookies


【解决方案1】:

通过查看调试诊断日志,我发现该问题与使用无效用户名/处理程序而不是防伪的 twitter 提要有关。这导致了 system.stackoverflowexception 并使应用程序池崩溃。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-05
    • 2013-08-08
    • 1970-01-01
    • 2017-03-08
    • 1970-01-01
    • 2015-06-17
    • 2018-06-19
    相关资源
    最近更新 更多