Tuesday, January 1, 2008

"The state information is invalid for this page and might be corrupted" Using ASP.NET AJAX

When you're using ASP.NET AJAX and the user accesses your site using Firefox, the user may see an error message that says "The state information is invalid for this page and might be corrupted." This seems to be caused by Firefox's methods for saving session information in its cache. There are a couple of ways to make sure this doesn't happen, depending on how extensive you want to disable the cache. In my case, I just wanted to do it on one page, so at the top of Page_Load I added:
Response.Cache.SetNoStore();
You could also set this in the page declaration with:

<%@ 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" %>

You could also add something like the below to Web.config:

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

6 comments:

Unknown said...

Dear Mattio,

Wow...Great Post...I got the same problem "The state information is invalid for this page and might be corrupted" and tried on so many web sites for the solution. I couldn't find the solution and spent lot of my time. Your solution is exceptional and worked well. Thanks alot for your post.

Regards,
Veera.

mrlance said...

shot mattio! u da man!

Anonymous said...

You guys rock! I just updated the web.config file with the information from this article and "voila!" A problem that I've been trying to get fixed for over two weeks is now magically resolved! Thank you!!!! :-)

Bhavesh Jogani said...

Hi guys.. I am getting same error, i implemeted all these solutions, but it could not resolve the issue. when i remove jquery then update panel works otherwise it works only 2 time and third time it generates error.
If anyone have any solution, please post here...

Unknown said...

Thanks for the great solution, i had a old website with ASP.NET 1.0 with this problem... searched for 3 days before i came on your blog! thnx a lot!

Anonymous said...

great u guy!!
It works !
Thanks,Sir!!