ASP.NET FIX FOR “The serialized data is invalid” ERROR

asp.net developers… have you fallen victim to the dastardly error “The serialized data is invalid“? have you like me tried to reproduce the error during testing only to come up empty handed? well hopefully my latest ASP.Net discovery will help you rid yourself of this pain-in-the-neck bug.

i was recieving this error on a website too frequently to ignore. it appeared that most of the user-agents that were tripping the error were FireFox browsers, with some Opera browsers thrown in for good measure and it wouldn’t be a website bug without a couple of IE’s mixing it up too. however, user-agent was the wrong thing for me to be looking at… it reall boiled down to internet connection speed. yes indeed, dial up users are the best users of all… if you’re trying to code to the nth degree for page load times… who needs rich media anyhow 🙂

(need a >> dialup emulator)

THE ROOT PROBLEM:
when users perform a post-back and the page is not fully loaded (including all of asp.net’s javascript overhead junk) guess what… “The serialized data is invalid” ouch… this is hard to reproduce when you are connecting to your site on a blazing fast modern broadband connection (i like rich media) or locally on a dev box… because the page is inherently going to load so fast that you won’t have time to click a button, drop down menu or whatever other control on your asp.net web page that might post back.

THE FIX:
pre-loaders. you know… the kind of “please wait while the page loads” screens you see when you search almost any serious airfare site (expedia, travlocity, orbitz). pre-loaders prevent users from doing anything until the entire page loads. however, this may add a percieved slowness to your site. i personally don’t mind them… i mean it’s great that google can search 800000000000 billion pages in 1 second… but they also have more invested in data caching and indexing than that most businesses (minus oil companies) could imagine ever getting to spend.

so there you go… when i started looking for the cause of “The serialized data is invalid” i found a lot of chat sites and forums where people where asking and not getting answers…and i’d love to go spread the word, but perhaps the search engines will be so kind to bring anybody searching for “The serialized data is invalid” to this little post… and hopefully this does indeed resolve your issue as it has mine. cause i sure didn’t find it on microsoft.com or the msdn or asp.net (the website)

by the way, does this look familiar:

STACKTRACE: at System.Web.UI.ObjectStateFormatter.Deserialize(Stream inputStream) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) at System.Web.UI.SessionPageStatePersister.Load()

uggh