Tuesday 22 December 2009

Webcontrol being serialized by ASP.NET but not added to Session state

I had an issue where I had a property on a webcontrol that was being added to the session state (StateService). The property object was marked as serializable. But for some reason ASP.NET was trying to add the webcontrol to the session by serializing it and a serialization exception was being thrown.

After quite a bit of investigation I found this very useful article.

In conclusion, on one of my child properties there was an event which was being assigned to an event handler within the page load of the webcontrol. Applying the workaround mentioned in the article solved my problem.

No comments: