1: <system.web>
2: <pages enableViewState="false" />
3: </system.web>
or, if you have the below settings or something similar to these
1: <pages>
2: <namespaces>
3: <clear/>
4: <add namespace="System"/>
5: <add namespace="System.Web.Security"/>
6: <add namespace="System.Web.UI.HtmlControls"/>
7: </namespaces>
8: </pages>
just replace <pages> with <pages enableViewState=”false”> and keep the rest of the lines as they are. See below:
1: <pages enableViewState="false">
2: <namespaces>
3: <clear/>
4: <add namespace="System"/>
5: <!-- something more here -->
6: </namespaces>
7: </pages>
So What Happens Now?

- Disable ViewState from the MasterPage. The ViewState will be inherited.
- Move ViewState into a session of your choise, to keep the form data or move the data and keep it intro a cookie. Don’t forget to clear the cookie data when it is no longer needed.
- You may disable ViewState from the Properties window of each component on the ASP .NET page.
- Disabling the ViewState from web.config only decreases the id=”__VIEWSTATE” value=”" data to something smaller.
- Anyway, I strongly recommend using HttpCompression instead. It is safer and may keep your site errors free. 78 kb of ViewState value data is a lot for a page to load.
- Natty Gur posted another method to disable ViewState (setting EnableViewState property to false in web.config, but also keep the data).
- “Spend less time writing wrongheaded plumbing code to replace ViewState, and instead learn how to use it effectively and efficiently.” said Scott Hanselman.
Use HTTPCompression Instead
I rather use HttpCompression with the Blowery HttpCompression Module instead of trying to fix ViewState’s size.1: <configSections>
2: <sectionGroup name="blowery.web">
3: <section name="httpCompressionModule" type="
blowery.Web.HttpModules.HttpCompressionModuleSectionHandler, HttpCompressionModule"/>
4: </sectionGroup>
5: </configSections>
6: <blowery.web>
7: <httpCompressionModule preferredAlgorithm="gzip" compressionLevel="high"/>
8: </blowery.web>
9: <system.web>
As a downside, some versions of Internet Explorer and other old browsers may experience some problems with the HttpCompression.
So, what are you choosing: HttpCompression or ViewState (disabled)? I am looking forward to your comments.
Cheers,