Home About Us SQL Interview Book Contact Us RSS
Articles
Tools
Code Snippets
Links
Tips & Tricks
FAQ
Resources
Articles
Code Snippets
Links
FAQ
Resources

Saravana Kumar
Vinod Kumar


ViewState is Corrupt or Invalid for this page

When you access the Server.transfer("Pagename","true") utility in an aspx page, you will get the following error.

          The View State is invalid for this page and might be corrupted

CAUSE

This problem occurs because the EnableViewStateMac attribute of the <pages> element is set to true by default. When this attribute is set to true, ASP.NET runs a message authentication check (MAC) on the view state of the page when the page is posted back from the client. This check determines if the view state of the page was modified on the client. For security purposes, it is recommended that you keep this attribute set to true.

When you call the Server.Transfer method and set the second parameter to true, you preserve the QueryString and the Form collections. One of the form fields is the hidden __VIEWSTATE form field, which holds the view state for the page. The view state message authentication check fails because the message authentication check only checks each page. Therefore, the view state from the page that calls Server.Transfer is not valid on the destination page.

View state is page scoped and is valid for that page only. View state should not be transferred across pages

For more detail on this error and resolution, refer the following links

PRB: "View State Is Invalid" Error Message When You Use Server.Transfer

If you didnt get this error because of this reason, then refer this links to know more details about viewstate problems.

  1. FIX: "The View State Is Invalid for This Page and Might Be Corrupted" Error Message in ASP.NET 
  2. View State is corrupted when view state contains object that have long decimals