Wednesday, February 13, 2008

.NET AJAX (ATLAS) Problem : The state information is invalid for this page and might be corrupt

I did lot of R&D and checked several sites for this. Finally I got few leads. This problem revolves around the VIEWSTATE of application. I checked the BLOG of Syed Ghulam Akbar that talks about the size of Viewstate. It suggests that you remove the size limitation of VIEWSTATE to solve the problem. A comment was there in his blog that said that following script can help resolve the problem...

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoading(function() {
var f = document.getElementById(“__VIEWSTATEFIELDCOUNT”);
if (f) f.parentNode.removeChild(f);
});

 

Another BLOG that I checked suggested that change the CACHE settings so that browsers like Firefox do not generate this error. Command Response.Cache.SetNoStore() is the quickest work-around. Or you can manage this in the Page Declaration by using...

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="account.aspx.cs" Inherits="Main" Title="My Account" EnableViewStateMac ="false" EnableSessionState="True" EnableEventValidation ="false" ValidateRequest ="false" ViewStateEncryptionMode ="Never" %>

Or by changing the WEB.CONFIG file...

<pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode ="Never">

Remember, if you are doing this WEB.CONFIG change, than you should check with this validateRequest parameter. Like in my case, I was having some HTML content being entered by user, so have to explicitly enable validateRequest on selected pages.

 

References:

http://syedgakbar.wordpress.com/2007/11/08/one-possible-reason-for-%E2%80%9Cthe-state-information-is-invalid-for-this-page%E2%80%A6%E2%80%9D-exception/

http://renditionprotocol.blogspot.com/2007/01/state-information-is-invalid-for-this.html

0 comments: