Tuesday, March 26, 2013

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

Hello Mates,

While working on a ASP.NET project in framework 4.0 i faced a strange error. It was working fine on development machine but failed on server. I google around and spent my 6 to 7 hours to fix the issue. I have tried with making changes in Web.Config and in the page directives but in vain. Finally i decided to troubleshoot my code line by line and point out the issue. The Error was...

The state information is invalid for this page and might be corrupted. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.
Source Error: 
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
1. Add a "Debug=true" directive at the top of the file that generated the error. Example:
  <%@ Page Language="C#" Debug="true" %>
2) Add the following section to the configuration file of your application:
<configuration>   <system.web>       <compilation debug="true"/>   </system.web></configuration>

Everything was perfectly coded. I was using JQuery .load() function to load an external ASP.net page in my master page which was the cause of this error. I tried by commenting the JQuery function and it worked fine for me. It was also causing to update panel to stop postback. None of my control in my update panel was posting back due to this .load() function.

The JQuery function was also fine and properly used. The problem was in the page that i was loading.  I simply removed HTML tags like <html>,<head> and <body> from the target page that i was going to load and everything works fine. See the images below that what i have removed.



It solved my problem. May be it won't be help full to you but at least it can give you an idea that this can be reason as well for that issue.

Happy Codding :)

No comments:

Post a Comment