Mike
Mike

Reputation:

Cannot serialize Object to ViewState only Session

I have a class that is marked as serializable and have no problem storing it in the Session but when I attempt to save it in the ViewState I get:

Sys.WebForms.PageRequestManagerServerErrorException: Error serializing value

Upvotes: 4

Views: 5194

Answers (2)

Ronald Wildenberg
Ronald Wildenberg

Reputation: 32134

The reason is that view state serialization is done by the LosFormatter class while session serialization is done by the BinaryFormatter class. The two are subtly different and one of these subtle differences is probably causing your problem.

Take a look at this article and the documentation for LosFormatter to see if you can find some clues about what is causing your problem.

Upvotes: 3

Robert Koritnik
Robert Koritnik

Reputation: 105059

Well it also depends what kind of session do you use. If it's in-proc, then serialization doesn't take place at all. Your objects get stored into memory.

Upvotes: 0

Related Questions