无效视图状态错误

发布于 2024-07-14 08:38:11 字数 1433 浏览 5 评论 0原文

我收到有关 ScriptResource.axd 的无效视图状态错误。 只是想知道你们中是否有人可以帮助我解决这个问题。 错误是:

2009-02-24 09:46:30,021 [13] DEBUG ASP.global_asax [(null)] - Request start - URL: /Web/ScriptResource.axd?d=E9hlvtsn8Gr1MyjysW1gFDFYr4CVwstY-sC22tRu5V8d7UyEYz3FhVYGrlhY87n2ihgKh58RrMRhK-Yk2WcQahEaCg_asTInqHK
2009-02-24 09:46:30,021 [13] DEBUG ASP.global_asax [(null)] - Application_AuthenticateRequest started
2009-02-24 09:46:30,021 [13] ERROR ASP.global_asax [(null)] - Unexpected error.  User presented with Site Error page.
System.Web.HttpException: Invalid viewstate.
   at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
   at System.Web.UI.Page.DecryptString(String s)
   at System.Web.Handlers.ScriptResourceHandler.DecryptParameter(NameValueCollection queryString)
   at System.Web.Handlers.ScriptResourceHandler.ProcessRequestInternal(HttpResponse response, NameValueCollection queryString, VirtualFileReader fileReader)
   at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context)
   at System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

这种情况发生在生产环境中。 我无法在开发或测试环境中重现此问题。 此外,这些页面只能由经过身份验证的用户访问。 如果你能对这个问题有所了解的话那就太好了。

I'm getting an invalid viewstate error with regard to the ScriptResource.axd. Just wondering if anyone of you could help me on this. Error is:

2009-02-24 09:46:30,021 [13] DEBUG ASP.global_asax [(null)] - Request start - URL: /Web/ScriptResource.axd?d=E9hlvtsn8Gr1MyjysW1gFDFYr4CVwstY-sC22tRu5V8d7UyEYz3FhVYGrlhY87n2ihgKh58RrMRhK-Yk2WcQahEaCg_asTInqHK
2009-02-24 09:46:30,021 [13] DEBUG ASP.global_asax [(null)] - Application_AuthenticateRequest started
2009-02-24 09:46:30,021 [13] ERROR ASP.global_asax [(null)] - Unexpected error.  User presented with Site Error page.
System.Web.HttpException: Invalid viewstate.
   at System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType)
   at System.Web.UI.Page.DecryptString(String s)
   at System.Web.Handlers.ScriptResourceHandler.DecryptParameter(NameValueCollection queryString)
   at System.Web.Handlers.ScriptResourceHandler.ProcessRequestInternal(HttpResponse response, NameValueCollection queryString, VirtualFileReader fileReader)
   at System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context)
   at System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

This happens in production environment. I'm unable to reproduce this in dev nor test environments. Also these pages can only be accessed by authenticated users. It would be really if you could shed some light on this matter.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

披肩女神 2024-07-21 08:38:11

我认为不同的浏览器会因不同的原因而发生这些错误,这就是很难追踪的原因。

IE8 错误

微软表示 IE8 中的错误会(在某些情况下)向服务器生成虚假请求,这不会影响用户,但会导致服务器端记录错误。

请参阅此处的讨论:Bug IE8 – 4K 下降 – “无效视图状态”正在加载 ScriptResource.axd (编辑:由于某种原因,链接现在需要登录,抱歉)

...特别是 EricLaw-MSFT 的更新,他说:

值得一提的是,任何在 IE6/IE7 或 Firefox 中遇到问题的人都会遇到与下面描述的 IE8 问题无关的不同问题。

此博客文章还描述了这些错误: IE8 的 Lookahead Downloader 中的错误

他们说改变你设置 Content-Type 的方式将有助于解决一些错误,尽管不是全部 - 他们说这是由各种模糊的情况引起的,但他们仍然看着。

更新:自 2010 年 4 月 1 日起,这些 IE8 错误已通过 IE8 累积更新 (KB980182) 得到修复。
本文:IE8 Lookahead 下载器已修复< /a> 提供有关错误和其他可能/部分解决方法的更多详细信息(例如 这个) 除了等待世界上的每个人下载修复程序之外。

其他浏览器

还没有弄清楚,但其他浏览器也会生成这些错误,大概是出于不同的原因。

网络场

此问题不仅限于在网络场上运行的网站,但如果您正在运行网络场,请查看 jesal 的回答可能会有所帮助

I think these errors happen with different browsers for different reasons, which is what makes it so hard to track down.

IE8 Bug

Microsoft have said a bug in IE8 will (in some circumstances) generate spurious requests to the server, that do not affect the user but do lead to errors being logged at the server side.

See this discussion here: Bug IE8 – 4K dropped - "Invalid viewstate" when loading ScriptResource.axd (edit: link now requires login for some reason, sorry)

... particularly EricLaw-MSFT's update when he says:

It is worth mentioning that anyone who is experiencing a problem here in IE6/IE7 or Firefox is encountering a different problem that is not related to the IE8 issue described below.

This blog post also describes the bugs: Bugs in IE8's Lookahead Downloader

They say changing the way you set Content-Type will help with some of the errors, although not all of them - they say it is caused by various obscure circumstances that they are still looking at.

Update: As of 01/Apr/2010, these IE8 bugs have been fixed, via IE8 Cumulative Update (KB980182).
This post: IE8 Lookahead Downloader Fixed gives more detail on the bugs and other possible/partial workarounds (e.g this one) other than waiting for everyone in the world to download the fix.

Other Browsers

Haven't figured it out yet, but other browsers are also generating these errors, presumably for different reasons.

Web Farms

This problem is not restricted to sites running on web farms, but if you are running a farm, check out this answer by jesal which may help

じ违心 2024-07-21 08:38:11

如前所述,如果您使用网络农场并且机器密钥不同步,则可能会发生这种情况。

另一种可能性是组装日期是在未来。 这会导致各种晦涩的问题,值得检查。 也许您的服务器位于不同的时区?

As said, this might happen if you are using a Web Farm and the machine keys are not in sync.

Another possibility is that the assembly date is in the future. This leads to all sorts of obscure problems and is worth checking. Maybe your server is in a different time zone?

安静被遗忘 2024-07-21 08:38:11

我建议查看这个...它基本上概述了根据文档类型可能发生这种情况的一些情况。 我们遇到了类似的问题,而且它似乎只是不规律地显示......对我们来说,这是我们的 XHTML 文档类型和页面上的 javascript 之间的冲突。 我们能够通过确保所有 javascript 都正确包装在标签中来解决这个问题。

<script>
     mycode;
</script>

这可能

<script>
// <![CDATA[
    mycode;
// ]]>
</script>

不是一个相同的问题,但如果您有一个 xhtml 文档类型,请查看是否有不合法 XML 的未转义字符(例如“<”字符)。

I would suggest looking at this...it basically outlines some cases where this can happen depending on the doctype. We had a similar issue, and it seemed to only show up erratically...for us it was a conflict between our XHTML doctype and the javascript we had on the page. We were able to solve it by insuring that all of our javascript was correctly wrapped in tags.

<script>
     mycode;
</script>

would become

<script>
// <![CDATA[
    mycode;
// ]]>
</script>

This may not be an identical issue, but if you have an xhtml doctype, look to see if you have unescaped characters that are not legal XML somewhere (such as '<' characters).

静谧幽蓝 2024-07-21 08:38:11

MS 建议不要使用元标记和设置声明您的字符集而是将其作为 HTTP 标头。

因此,删除

并添加

Response.AddHeader("Content-Type" , "text/html; charset=utf-8");

MS recommends not declaring your charset using a meta tag and setting it as a HTTP header instead.

So remove

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

and add

Response.AddHeader("Content-Type", "text/html; charset=utf-8");

愛上了 2024-07-21 08:38:11

如果接收 scriptresource.axd 请求的应用程序池的 machineKey 与提供原始页面的应用程序池的 machineKey 不同,则可能会发生这种情况。 如果您使用的是网络场,则最有可能出现这种情况。 如果应用程序池重新启动,它也可能发生在单个服务器上,因为将生成新的计算机密钥。 任一问题的解决方案都是在 web.config 中放置一个固定的 machineKey。

This can happen if the machineKey of the app pool that receives the request for scriptresource.axd is different from that of the app pool that served the original page. This is most likely if you're using a web farm. It can also happen on a single server if the app pool restarts, as a new machine key will be generated. The solution to either is to put an fixed machineKey in your web.config.

望喜 2024-07-21 08:38:11

我注意到 Firefox 3.1 Beta 会导致无效视图状态错误。 您可能需要查看日志以了解发生这些错误时正在使用的浏览器。

I have noticed that the Firefox 3.1 Beta causes invalid viewstate errors. You might want to review your logs to see what browser that is being used when these errors occur.

追风人 2024-07-21 08:38:11

这里同样的错误
用户代理:Mozilla/4.0(兼容;MSIE 7.0;AOL 9.0;Windows NT 6.0;Trident/4.0;GTB5;SLCC1;.NET CLR 2.0.50727;Media Center PC 5.0;.NET CLR 3.5.30729;.NET CLR 3.0.30618)

我尝试修改/删除 doctype 声明并扭曲 //

目前所有都来自同一 IP

Same error here for
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.0; Windows NT 6.0; Trident/4.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618)

I tried modifying/removing doctype declaration and warping the javascript in // <![CDATA[ and there are still exceptions...

For the moment all came from the same IP

梦境 2024-07-21 08:38:11

我遇到了同样的错误,它们实际上是在最近一两个月才开始的,它发生在我们的几个网站上,自 12 月以来我们没有更改任何错误。 这让我认为配置更改或 Windows 更新正在影响它。

I'm getting the same errors, they actually just started in the last month or two, its been happening on a couple of our sites and we haven't changed any of them since December. This makes me think a configuration change or windows update is effecting it.

今天小雨转甜 2024-07-21 08:38:11

视图状态有多大? 某些代理服务器会截断较大的视图状态。

由于默认情况下打开视图状态,因此很容易滥用视图状态。 如果您确实有一个很大的视图状态,那么您可能需要考虑在不需要它的控件上禁用视图状态。

How large is the view state? Some proxy servers will truncate a large view state.

It is easy to abuse viewstate since it is turned on by default. If you do have a large viewstate then you probably want to look into disabling view state on controls that do not need it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文