I have a page that has a really huge viewstate (>300KB). ...Yeah, I know. I've narrowed this anomaly down to one user control, but am having trouble determining what exactly that control is putting in there.
I've overridden SavePageStateToPersistenceMedium in the page, but am not great at working with the viewstate object passed in. Could I pass it in to some recursive function that would print out everything that's in the object?
I've tried using freely available viewstate decoders, but none have worked. I always get errors when it attempts to deserialize the viewstate.
I'm pretty much looking for a code snippet here.
Thanks,
Mark
Thanks for the traceing suggestion, esp. the trace.axd thing. But that still only tells me how big the controls are, it doesn't tell me what's in the viewstate. I want to be able to see if there are objects that I'm erroneously serializing to viewstate.
views:
468answers:
4
+1
A:
I used to use trace.axd. It lists each request and dumps the contents of the viewstate. You'll have to enable tracing in web.config. If you've got lots of requests you'll want to update the cache size to more than 10.
Arnshea
2009-03-20 20:31:53
A:
Regarding the issue with viewstate decoders, you might have the viewstate encrypted. Check this post with comments/links on it: http://www.testingreflections.com/node/view/3424.
Update: try turning it off completely on the pages element in the web.config:
<pages ... viewStateEncryptionMode="Never" ... />
View the view state section in this msdn doc How To: Configure MachineKey in ASP.NET 2.0
eglasius
2009-03-20 20:45:48
I removed the 'machineKey' setting from my web.config, but I still get "There was an error decoding the ViewState string: The serialized data is invalid." in my decoder.
MStodd
2009-03-24 20:07:55
@MStodd added an update with more info, check it out to completely discard it being encrypted.
eglasius
2009-03-24 23:42:00
A:
I would just add Trace="true" to the page directive on your local machine. The control tree section will show you the viewstate size of each control.
wulimaster
2009-03-20 21:03:22
I wish it would work, but I keep getting "There was an error decoding the ViewState string: The serialized data is invalid." in my decoder. This is even after I removed the 'machineKey' setting from web.config.
MStodd
2009-03-24 20:08:55