Local vs. Global Web Form Viewstate

38 sec read

In ASP.NET, as you may already know, you can set most of the Page Directives at the web.config Pages section if you need these directives to apply to all pages contained in your Web application.

So setting EnableViewState to false, for example, in web.config’s Pages section means that none of your page will use ViewState to persist state for its controls. So “what happens if I have an exception, a page that needs viewstate” you might ask.

In most of the cases setting the corresponding directive’s value at the Page declaration normally overrides the global web.config one, but that’s not the case with EnableViewState. If this directive is set to the web.config file, then no matter what you type on the Page won’t change the globally set value.

If you have an exception then you’ll have to remove the global setting completely and specify the directive at each web form in your web application.

So now you’ll know what’s going on next time you’ll find yourself searching why on earth viewstate is disabled even though you’ve explicitly set EnableViewState=”true” at the Page directive.

Cloud development with Azure and Visual Studio

This session is so awesome, I just had to post it here so that I can play it over and over again… What great...
kpantos
5 sec read

StressStimulus stress testing tool

If you ever created a professional website/application you’ll probably know the value (you’ve probably learned it the hard way as I did ) of...
kpantos
26 sec read

Debugging Web Sites using IIS Express

Microsoft recently released a new flavor of IIS 7.x that is optimized for developer scenarios called “IIS Express” as part of WebMatrix. IIS Express...
kpantos
56 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *