Why Viewstate can contain only serializable object?

后端 未结 4 590
野的像风
野的像风 2020-12-19 13:28

I have a simple class with some properties and other data. Untill i stick serializable attribute to the class, i cannot save the object of the class into the viewstate.

4条回答
  •  独厮守ぢ
    2020-12-19 14:01

    I think this summarizes the answer: The state goes out of control from ther Asp.Net code to the HTTP handler which does not understand your code which will go out of scope, and must serialize it in a datastore (it's that lot of garbage you see when you view the source of a asp.net page) then give it back when another postback requires it.

    enter image description here

提交回复
热议问题