CODEDIGEST
Home Articles CodeDigest Tutorials FAQs
Home > CodeDigest >  
Technologies
 


Disable ViewState for a Set of ASP.Net Pages in a Folder in Asp.Net
Submitted By Bala Murugan
On 3/21/2010 7:01:16 AM
Tags: ASP.Net,CodeDigest  

Disable ViewState for a Set of ASP.Net Pages in a Folder

 

At times, we need to disable the viewstate for a set of aspx pages contained in a folder in our solution. We normally do this to increase the performance of the website for those pages where it is not required to have viewstate enabled.

 

A very easy way is to set EnableViewState property to false in the Page directive of every page.

 

An alternate and very simple way is to use location tag in web.config and disable the viewstate for the whole folder.

 

Refer below,
<location path="FolderName">
  <system.web>
   <pages enableViewState="false"/>   
  </system.web>
</location>

 

You need to put the above setting inside the <configuration> tag in Web.Config file.

 

Note:
Disabling viewstate may cause your page controls not work properly (due to the fact that it cannot be constructed back in the postback) in the pages contained in the folder.  Hence, in this case, make sure you are again binding or constructing the controls in every postbacks.


 

Recent Codes
  • View All Codes..