Tuesday, December 23, 2008

Viewing the viewstate of asp.net

Most of us do not want to bother with the viewstate when we develop applications, but for large apps, the viewstate can become quite big and therefore a hindrance to performance. If we are not aware of what things may potentially end up in the viewstate, we'll get viewstate's as large as 100KB. In one app I was developing, the partial postback returned 232KB of data, although the viewstate was only 10KB, other things like the ArcGIS ADF's json callback data, update panel data etc. constituted the remainder. 
I have tried to quickly  understand how to minimize viewstate and its bloating, but this is a topic that requires a few hours of careful thinking. 
One thing to keep in mind is that postback data is different from viewstate data. Postback data is inspected and asp.net server-side controls are updated with the postback data, but that mechanism is independent of viewstate data. 
Here's some great articles on understanding asp.net viewstate:
1) Understanding ASP.NET View State- very good article from msdn written by Scott Mitchell from 4GuysFromRolla
Some tools to inspect viewstate data:
1) asp.net viewstate helper from binary fortress software - nice tool but can't dissect all of the viewstate into meaningful info
2) CodeProject: Yet, another ViewState viewer- havent' used it, requires you to login to download.
4) Denis Bauer's ViewstateViewer-havent' used it
5) Nikhil Kothari's Web Development Helper browser extension for IE - article on it

No comments:

Post a Comment