随机无效视图状态错误 [英] Random Invalid Viewstate Error

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

问题描述

我知道关于这个主题有很多问题,我已经阅读了所有问题.

I know there are a lot of questions on this topic and I have read them all.

我使用的是 IIS8、.Net 4.5.

I'm using IIS8, .Net 4.5.

用户随机收到无效的视图状态错误,我无法弄清楚.一旦发生这种情况,他们重新进入网站的唯一方法就是清除浏览器缓存.

Users randomly get an invalid viewstate error, I can't figure it out. Once this happens the only way they can get back into the site is to clear browser cache.

在我的 web.config 中,我有:

In my web.config I have:

<system.web>
<machineKey validationKey='....key here'   decryptionKey='....decrypt key is valid here'   validation='SHA1'/>
    <!--<hostingEnvironment shadowCopyBinAssemblies="false" />-->
    <authentication mode="None" />
    <compilation targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
...
</system.web>

我在虚拟专用服务器上运行,但我还没有找到大于 9kb 的视图状态.

I'm running on a virtual private server, and I've yet to find a viewstate larger than 9kb.

我的应用程序池设置为每天凌晨 3:00 重新启动一次.

My application pool is set to restart at 3:00am, once per day.

我的页面使用更新面板,也许用户正在点击返回"?但我看到它只是在没有点击返回的情况下访问页面.

My page uses update panels, maybe the user is clicking 'back'? But I've seen it happen just visiting the page with no clicking back.

我注意到的一件事是我有 3 个不同的站点使用相同的应用程序池标识,但应用程序池是独立的.machine.xml 中没有机器密钥,只有在我的 web.config 中.

One thing I noticed is I have 3 different sites using the same application pool identity, but the application pools are seperate. There is no machine keys in machine.xml, but only in my web.config.

推荐答案

调查的几种可能性:

  1. 更新面板正在更改表单字段值(用于计算 ViewState),然后页面被 POST 回服务器,在那里新值使验证失败.请参阅这篇文章

您启用了缓存(执行 HTTP 标头跟踪 - 确保您没有打开开发工具),这会导致使用 UpdatePanel 处理问题生成无效的 ViewState.

You have caching enabled (perform a trace of HTTP headers - make sure you don't have dev tools open) which is causing invalid ViewState to be generated w/ UpdatePanel gumming things up.

您是否在任何地方使用 Server.Execute?(相同的见上面的链接)

Are you using Server.Execute anywhere? (see above link for same)

(不太可能)您的虚拟专用服务器"是否迁移到不同的硬件(可能您不知道)?

(less likely) Does your "Virtual Private Server" get migrated to different hardware (perhaps without you knowing it)?

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

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