我应该忽略偶尔的无效的viewstate错误吗? [英] Should I ignore the occasional Invalid viewstate error?

查看:145
本文介绍了我应该忽略偶尔的无效的viewstate错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每天(每天一次),我们在ASP.NET 3.5应用程序的日志中看到以下类型的错误




  • 无效的viewstate

  • 无效的回发或回调参数



ASP.NET应用程序的时间会发生什么?有人会建议我们花费大量时间来诊断导致问题的原因?

解决方案

这取决于。由于各种原因,无效的viewstate可能会发生。


  1. Viewstate太大,在用户在页面上导致回发之前没有完成呈现。修复通常是禁用触发回发的所有控​​件,并在页面加载完成后启用客户端 - 请参阅 http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error .aspx

  2. 您正在使用viewstate MAC(您应该是出于安全考虑),但您尚未设置机器密钥,应用程序池已循环生成新的。不要忘了设置一个ViewStateUserKey。

  3. 有人在Mac上使用旧版本的IE来截断隐藏的表单域。在这种情况下,您需要将视图状态从页面中移至会话状态

  4. Viewstate MAC问题通常表明您处于一个Web场,并忘记在web.config中设置机器密钥。但是,如果你这样做了,那么可能是有人试图做坏事(机器人发布评论,有人试图触发残疾人控制的事件等)。如果只是为了排除潜在的安全问题,应该跟踪这些原因。 / li>

无论你做什么 不要 关闭viewstate或事件验证。 p>

Every now and then (once every day or so) we're seeing the following types of errors in our logs for an ASP.NET 3.5 application

  • Invalid viewstate
  • Invalid postback or callback argument

Are these something that "just happens" from time-to-time with an ASP.NET application? Would anyone recommend we spend a lot of time trying to diagnose what's causing the issues?

解决方案

Well it depends. Invalid viewstate can happen for a variety of reasons.

  1. Viewstate is too big and has not finished rendering before a user causes a postback on the page. The fix is generally to disable all controls that trigger postbacks and enable them client side once the page has finished loading - see http://blogs.msdn.com/tom/archive/2008/03/14/validation-of-viewstate-mac-failed-error.aspx
  2. You are using viewstate MACs (and you should be, for security reasons) but you have not set a machine key and the application pool has recycled generating a new one. Don't forget to set a ViewStateUserKey.
  3. Someone is using an old version of IE on the mac where it truncates hidden form fields. In this case you'll need to move viewstate out of the page into session state.
  4. Viewstate MAC issues generally indicate you're on a web farm and have forgotten to set a machine key in web.config. However if you have done this then it is probably someone trying to do bad things (bots posting comments, someone trying to trigger events for disabled controls etc.) The cause of these should be tracked down if only to rule out potential security issues.

Whatever you do do not turn off viewstate or event validation.

这篇关于我应该忽略偶尔的无效的viewstate错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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