__VIEWSTATE

The value of this element is a base64-encoded string that acts as a state repository for the page. Any elements on a page whose contents are not implicitly posted back via the standard form POST mechanism have their values saved to and restored from this hidden field. It is also used to propagate supplemental state for controlsor example, what prior value was stored in a control so that server-side change notifications can be issued. While the technique of propagating state using hidden input fields is common practice in Web applications, ASP.NET takes it a step further and uses it to unify the server-side control model by ensuring that all elements marked with runat=server retain their state across post-backs.

   

VIEWSTATE就是发送到client端的当前页面的状态, 但貌似只有在代码中赋予的值(方式2)才会在GET请求时被包含在VIEWSTATE, 而对于页面中直接指定的值(方式1), GET请求中不会被包含在VIEWSTATE.

   

方式1:

编译出来的代码为:

   

方式2:

   

   

编译出来的代码为:

   

原文地址:https://www.cnblogs.com/smwikipedia/p/2190411.html