验证视图状态MAC失败-视图状态错误 [英] Validation of viewstate MAC failed -View State Error

查看:289
本文介绍了验证视图状态MAC失败-视图状态错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站中,当一个网页闲置超过5分钟时,该页面直到我刷新后才起作用.发生以下错误:

In my website, when a web page is idle for more than 5 minutes, then that page is not working until I refresh. The following error occurs:

错误: Sys.WebForms.PageRequestManagerServerErrorException: 验证视图状态MAC失败.如果 该应用程序由Web托管 场或集群,请确保 配置指定 相同的validationKey和validation 算法.无法使用自动生成 在集群中.

Error: Sys.WebForms.PageRequestManagerServerErrorException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

我已经在使用EnableEventValidation="false" ViewStateEncryptionMode="Never" ValidateRequest="false"

但是,没有任何东西对我有用.

But, nothing is working for me.

推荐答案

尽管这是一个老问题,但我还是会回答,因为它可能会对其他人有所帮助. 所以在过去的几天里我遇到了这个问题,我意识到在将cookie配置为HttpOnly并需要SSL后,我开始出现此错误:

Although it's an old question, I will answer anyway because it might help someone else. So I had this problem in the past few days, and I realized that I started getting this error after I configured my cookies as HttpOnly and Require SSL:

  </system.web>
    <httpCookies httpOnlyCookies="true" requireSSL="true" />
  </system.web>

结果是我只是忘记配置Visual Studio来打开我的网站的SSL URL.因此,只要打开常规网址,就无法发送Cookie,这就是导致错误的原因.

Turns out that I just forgot to configure Visual Studio to open the SSL URL of my website. So as long as it opened the regular Url, the cookies couldn't be sent, and that what caused the error.

为了更改默认的URL,您只需要弄清楚什么是SSL URL:在解决方案资源管理器上单击项目,然后按F4(不是右键单击->属性"),在那儿您将看到SLL URL.开发服务器部分.之后,转到项目属性页(右键单击->属性),然后在"Web"选项卡中,将SSL Url设置为Project Url.

In order to change the default Url, you simply need to figure out what is your SSL url: Click the project on solution explorer and press F4 (not Right Click -> Properties) and over there you'll see SLL URL under the the Development Server section. After that, go to the project properties page (Right Click -> Properties) and in the Web tab, put the SSL Url as the Project Url.

这篇关于验证视图状态MAC失败-视图状态错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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