今天收到一個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();
作用是告訴瀏覽器不要快取頁面面.在測試頁面成功,不會再發生錯誤.