Monday, March 14, 2011

Firefox; The state information is invalid for this page and might be corrupted.

I ran into an issue recently where a web application was throwing a System.Web.HttpException in Firefox with this message:

The state information is invalid for this page and might be corrupted.

It was easily reproduced in Firefox 3.6.13 and 3.6.15 when the user would do something on the page to cause a postback (e.g. click a button), and then use the browser's back button to go back to the previous section, and then use the browser's refresh button to refresh the page, and then click a button to cause another postback.

It seems this issue is only encountered in Firefox for ASP.Net websites that utilize ViewState and has the "autocomplete" form option enabled. In which case, Firefox attempts to "autocomplete" the form with values after the browser's refresh button is clicked, thus causing the ViewState to become invalid.

In my case, the solution was turning off the "autocomplete" attribute on the form:

<form id="form1" autocomplete="off" runat="server">
   ...
</form>

Although there are other solutions to turn "autocomplete" off at the input level, if you don't want to turn it off for the entire form.

Here are some articles that I referenced along the way during my research.

http://msdn.microsoft.com/en-us/library/ms533032(v=vs.85).aspx

http://ryanfarley.com/blog/archive/2005/02/23/1739.aspx

http://www.hanselman.com/blog/TurningOffAutoCompleteForTextBoxesInIEAndFireFox.aspx

http://lachlankeown.blogspot.com/2008/04/firefox-refresh-viewstate-updatepanel.html

http://ra-ajax.org/firefox-retains-form-element-values-on-refresh-including-the-viewstate-in-asp-net

https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion

0 comments: