Are objects stored in viewstate serialized? If so, how can I find the size of each viewstate["key"]?

StackOverflow https://stackoverflow.com/questions/21583205

  •  07-10-2022
  •  | 
  •  

Question

The viewstate of a c# asp.net app that I am working on stores a ton of stuff via ViewState["SomeKey"] not to mention behind the scene stuff for several grids etc... and it is bloated.

I'm tasked with getting the viewstate size down...

I have found that within the app, viewstate is used to store various objects used throughout the code and I would like to use something more appropriate that stays session side (like session["SomeKey"]) or simply repopulate the objects again serverside... anyway...

I'd like to find where the largest benefit can be achieved by finding the heaviest objects that are stored in viewstate throughout the code... That is assuming they are serialized which I guess they must be... rather than holding a reference and hoping the object is in memory when posted back???

I would like to do something like the following...

var vsSomeKey = ViewState["SomeObjectKey"];
vsSomeKey.length.....

... with the hope of finding how much space is being used in viewstate for this key at this point in time... Any ideas?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top