的防伪标记无法解密 [英] The anti-forgery token could not be decrypted

查看:3643
本文介绍了的防伪标记无法解密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格:

@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) {
@Html.AntiForgeryToken()
@Html.ValidationSummary()...

和行动:

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl, string City)
{
}

偶尔(每周一次),我得到的错误:

occasionally (once a week), I get the error:

的防伪标记不能被解密。如果这个应用程序是
  由Web场或群集承载,确保所有机器都运行
  ASP.NET Web页的相同版本和配置
  指定明确的加密和验证密钥。自动生成不能
  在集群中使用。

The anti-forgery token could not be decrypted. If this application is hosted by a Web Farm or cluster, ensure that all machines are running the same version of ASP.NET Web Pages and that the configuration specifies explicit encryption and validation keys. AutoGenerate cannot be used in a cluster.

我尝试添加到webconfig:

i try add to webconfig:

<machineKey validationKey="AutoGenerate,IsolateApps"  
    decryptionKey="AutoGenerate,IsolateApps" />

但错误依然,偶尔会出现

but the error still appears occasionally

我注意到,出现此错误,例如当一个人从一台计算机来了,然后试图在另一台计算机

I noticed this error occurs, for example when a person came from one computer and then trying another computer

推荐答案

我刚刚收到此错误,以及和,于我而言,它是由防伪标记引起相同的形式被应用了两次。第二个实例是从一个局部视图来让当时并不明显。

I just received this error as well and, in my case, it was caused by the anti-forgery token being applied twice in the same form. The second instance was coming from a partial view so wasn't immediately obvious.

这篇关于的防伪标记无法解密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆