Sunday, July 5, 2009

The serialized data is invalid

Many times when web page is getting loaded, the following error is thrown.



Possible Reason

Viewstate problem.

The major reason could be the View State. When the post back happens in the page but the page cannot load fully because of many reasons the error The serialized data is invalid" is thrown.

When we click on buttons or any controls making post backing before the page is completely loaded the error can happen.


Possible Solutions


1. Set the MaxPageStateFieldLength proprety of Pages in Web.config file


(The default value is -1 which means unlimited).

Example:

in web.config File.



It forces ViewState data to be splitted on multiple, smaller hidden fields.



2. Pre-loading Message

While the page is getting loaded, display message "Page is getting loaded".

Also prevent the post back of other controls before page is getting loaded completely.

No comments:

Post a Comment