Three solutions to ban ViewState


There are three ways to disable ViewState for a control, a page, and the entire application.

  1. control disabled: set the EnableViewState property of the control to false;
  2. page disabled: add EnableViewState=“false” in the Page instruction of the page;
  3. application disabled: add program code to the Web.Config file
<configuration>
<system.web>
<pages enableViewState="false"/>
</system.web>
< /configuration>

You can also disable EnableViewState=“false” in the page directive on the page Sometimes we found that ViewState could not transfer the value normally, maybe it was disabled, it is ok to enable it again!