Disabling View-State Made Simpler in ASP.NET 4.0
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.
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.
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.
How Can We Use Our Creative Power and Technological Opportunity to Address the Challenges of the 21st Century?
Gyorgyi Galik Feb 26, 2015