Other than because session storage is session-global to more than one page, why would you ever want to use the viewstate to hold values?
It seems kind of ridiculous to send any kind of information other than a few small query string like values, back and forth from the client to server. I mean what a waste of bandwidth(!), simply for storage purposes. The session, while global across multiple pages, seems like a completely superior alternative to the viewstate.
Especially with asp.net ajax controls and variants, the viewstate could quickly become bloated tracking the various states and variables of all those different controls and html elements.
But then why is there viewstate storage for page variables and objects at all?
Maybe I'm missing another great usage for the page's viewstate storage, does anyone know something out there?
Thanks for reading!
EDIT: Everyone had a great answer, sorry if I didn't pick yours.
Sessions run out, Viewstate does not - you can go back an hour later and your viewstate will still be available. Viewstate is also consistently available when you go back/forward on the website, Session changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With