x Share your thoughts on trends and content!

Disabling View-State Made Simpler in ASP.NET 4.0

by Jon Arild Tørresdal on Jan 30, 2009 |

ASP.NET 4.0 offers a new mechanism to enable/disable the view-state, controlling it becoming much easier than before. To store their state, ASP.NET controls have used view-state, enabled by default until now. This behavior resulted sometimes in large amounts of data being transferred between the client and the server.

The whole concept of view-state in ASP.NET is thoroughly covered in the blog post Truly Understanding Viewstate, by Dave Reed back in August 2006 and is recommended reading for all developers working on the ASP.NET platform. As Dave points out, “ViewState is a very misunderstood animal”, and should be used with care. Developers that have not experienced how view-state works, have sometimes been surprised when looking at the HTML returned to the client browser. If one is not conscious of how view-state is used, the size of the page returned to the user can be extremely big, resulting in potentially low performing websites.

At PDC2008, Scott Hunter, Program Manager for ASP.NET, talked about the ASP.NET 4.0 roadmap. In his talk he explained how view-state is changed in 4.0:

We’re going to give what we call granular control of view-state. Which means you can turn it off at the page, and just turn it on for the controls you want. Versus turning it on, and turning it off a million places. So it should be much easier to say: I want it off for the page, turn it on for these three controls, and it’s out of your way.

To summarize, this allows to:

  • Disable on page, enable on specific controls
  • Disable on control, enable on child controls

Also GridView/ListView is promised to work better without view-state.

Scott was asked if view-state would be disabled by default during an interview done by’s podcast, also recorded during PDC2008:

That’s up in the air. I would like to make it the default. Maybe it will be if you build a 4.0 application it’s off by default, while obviously if you’re doing multi targeting and doing 3.5 or 2.0 app you’re going to get the original behavior.

Scott’s complete PDC talk on ASP.NET roadmap contains more information on the changes to come in ASP.NET 4.0.

Rate this Article


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

General Feedback
Marketing and all content copyright © 2006-2016 C4Media Inc. hosted at Contegix, the best ISP we've ever worked with.
Privacy policy

We notice you're using an ad blocker

We understand why you use ad blockers. However to keep InfoQ free we need your support. InfoQ will not provide your data to third parties without individual opt-in consent. We only work with advertisers relevant to our readers. Please consider whitelisting us.