Search code examples
asp.netwebformsviewstate

Completely disabling view state for Web Application


I noticed, that even if i disable ViewState at application level (<pages enableViewState="false"/>) or at page level (EnableViewState="false" in page properties), you can still find hidden field for viewstate in page sources:

     <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="NSe2ZpTF4OoGVDqwwtGVO+/liqfw9gUFmsPSD0n169Su3I6VwhG8xgVaSe0iTUfiPp1x0FbW9q47hkfxgDCvxjd2Z9RKo7N+WljNcEezg4Q=" />

Why does it still exists in this case? What does ASP.net store in it?


Solution

  • Note that since Asp.Net 2.0, the __VIEWSTATE hidden field is not only storing ViewState but also ControlState.

    Control state is similar but independent of regular view state. Control state cannot be turned off, so if any control that needs control state is on your page, it will cause the __VIEWSTATE hidden field to appear in the rendered markup.

    Please see this page on MSDN for more info about control state.