Wrangling ASP.NET Viewstate

Inspired by Scott Hanselman's recent post on ASP.NET viewstate wrangling, here's a roundup of tips for dealing with that ornery viewstate stuff. The first rule of thumb, of course, is to turn it off whenever you can. But sometimes you can't.

I think the DotNetNuke developers were the first to realize that moving the viewstate to the bottom of the page makes the page much more Google-friendly. Google only indexes the first (n) bytes of the page, so if you have 12 kb of Base64 encoded schmutz in your header, that isn't exactly helping people find your pages via Google searches. Scott Mitchell compares and contrasts several methods of moving the viewstate input field to the bottom of the HTML form.

The benefits from compressing viewstate are somewhat marginal, nowhere near what you'd get from zipping plain text. but it's still worth trying. Scott Hanselman points us to a nifty base page class that automagically compresses viewstate for you.

There's also an interesting article on eggheadcafe about moving viewstate to the server. Peter Bromberg benchmarks the performance difference between viewstate on the client, and viewstate on the server in Session, Application, or Cache.

ASP.NET 2.0 brings a few much-needed improvements to Viewstate:

  • Viewstate can be safely disabled without destroying intrinsic control behaviors thanks to a new container, Controlstate.
  • An improved formatter class, ObjectStateFormatter, appears to reduce ViewState size by half.

Here's to progress. Now pardon me while I crack my bullwhip. Hyaa!!

Read more

Stay Gold, America

We are at an unprecedented point in American history, and I'm concerned we may lose sight of the American Dream.

By Jeff Atwood · · Comments

The Great Filter Comes For Us All

With a 13 billion year head start on evolution, why haven't any other forms of life in the universe contacted us by now? (Arrival is a fantastic movie. Watch it, but don't stop there - read the Story of Your Life novella it was based on

By Jeff Atwood · · Comments

I Fight For The Users

If you haven't been able to keep up with my blistering pace of one blog post per year, I don't blame you. There's a lot going on right now. It's a busy time. But let's pause and take a moment

By Jeff Atwood · · Comments

The 2030 Self-Driving Car Bet

It's my honor to announce that John Carmack and I have initiated a friendly bet of $10,000* to the 501(c)(3) charity of the winner’s choice: By January 1st, 2030, completely autonomous self-driving cars meeting SAE J3016 level 5 will be commercially available for passenger

By Jeff Atwood · · Comments