Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

C# Nuggets

ASP.NET 2.0: ViewState Numbers

Dino wrote an post on ViewState looking at the savings which can be obtained from ASP.Net v2 versus v1. He points to a page with 120K of ViewState which is 500K in total size. You can see the same page in ASP.Net v2 by replacing the 'www' in the URL with 'beta' here.

Using an unreleased version of my FireFox ASP.Net Development Helper add-in (quick plug!) shows the following about the ViewState:
112748 characters (Base64-encoding of 84561 bytes)
versus the following for the ASP.Net v1 site:
126636 characters (Base64-encoding of 94977 bytes)

One of the reasons for the large ViewState on that page is bad coding! The developer of the site chose to store full HTML hyperlinks in the viewstate - yes <a href="...">...</a> are stored many times. Clearly there's not much saving in ViewState size between ASP.Net v1 and ASP.Net v2 in this particular instance because strings are encoded in much the same way between ASP.Net v1 and ASP.Net v2 (the next version of the Firefox ASP.Net Web Developer Helper supports both v1 and v2 viewstate :-)

In summary, the ASP.Net v2 formatter is vastly improved over ASP.Net v1. It's a really fantastic formatter. However, as a responsible web developer, you need to pay attention to what you store in ViewState - and HTML markup is a really bad thing to store!

Sponsor
Published Thursday, July 21, 2005 10:16 AM by rbirkby

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

rbirkby said:

http://www.asp.net/ControlGallery/default.aspx?Category=7&tabindex=0 will be updated and will be about 400k in size (total). Side note, the code that runs both pages was written in 2001 (yeah, the beta site is just a recompile of the existing site with a new design). =)
July 26, 2005 7:45 PM
 

rbirkby said:

I plead guilty, I wrote the Control Gallery with the beta of ASP.NET 1.0 :(
July 26, 2005 8:26 PM
 

rbirkby said:

So...When is your Firefox extension coming out? Any plans? You've peaked my curiosity! :-)
July 27, 2005 2:22 AM
 

rbirkby said:

The new firefox extension features have been written for a _long_ time. There are just a couple of tricky-to-fix bugs still left to fix which has delayed the release.
July 28, 2005 10:01 AM

Leave a Comment

(required) 
(optional)
(required) 
Enter the code you see below

Submit