"The state information is invalid for this page and might be corrupted"错误的一个解决办法

今天收到一个bug,在FF 3.0.7上用浏览器的"后退"回到某一个页面,会出现"The state information is invalid for this page and might be corrupted"的错误,抛出信息:

 

Code
Error : The state information is invalid for this page and might be corrupted.
Detail:   
at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError)
at System.Web.UI.ClientScriptManager.EnsureEventValidationFieldLoaded()
at System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)
at System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)
at System.Web.UI.WebControls.HiddenField.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.WebControls.HiddenField.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

 

分析应该是ViewState校验出错产生的信息,正常浏览情况下不会出现问题.因为只有用"后退"之类的操作才会出现错误.就怀疑是浏览器的缓存问题,就在Page_Load加入:

 

Code
Response.Cache.SetNoStore();

 

作用是告诉浏览器不要缓存页面.在测试页面成功,不会再发生错误.

posted @ 2009-05-20 12:16  KenBlove  阅读(1486)  评论(0编辑  收藏  举报