ViewState is used when the page is writing back to restore the control tree on the page to what it was when the last page was viewed.
This allows you, for example, to control the GridView so that it maintains the state (what is shown in the GridView) on the reverse side, without resetting it to the same data.
The reason the ViewState is serialized and sent to the client by default (I think) is that this is the easiest way to get it back when the client sends the message back.
What if, for example, the user has several browser windows open with the same loaded page, and you have a view repository stored in the session? Assigning the correct view to different windows in this case, of course, can be allowed, but provided that the client explicitly published it, this is the easiest way.
However, you can have a view repository stored in the session. See for example this link .
Other features are available by implementing your own System.Web.UI.PageStatePersister
.
source share