本文发表在 rolia.net 枫下论坛viewstate的好处很明显,坏处我抄了几段在下面。一个东西即有好处又有坏处,又不是必须要用的,就选择不用了。Web forms对初学者还能省点时间,有几年经验后就因该觉得web forms model既不能省时间,也没品质。
it adds few Kbytes to the page. This effects the loading of the page in the client.
放个dategrid,load 点数据,postback,然后看sourcecode,viewstate占了90-99%,也就是说viewstate把页面变大了10倍到100倍,关这个点够头痛了
it is passed as plain text to the client. Anybody can tamper this value, because of this you shouldnt store any important data in the viewstate.
View state is one of the most important features of ASP.NET, not so much because of its technical relevance, but more because it makes the magic of the Web Forms model possible.
However, if used carelessly, view state can easily become a burden. Although ViewState is freely accessible in a hidden field called __VIEWSTATE, the view state information is not clear text. By default, a machine-specific authentication code is calculated on the data and appended to the view state string. The resulting text is then Base64 encoded only, but not encrypted. In order to make the view state more secure, the ASP.NET @Page directive supports an attribute called EnableViewStateMac whose only purpose is detecting any possible attempt at corrupting original data.更多精彩文章及讨论,请光临枫下论坛 rolia.net
it adds few Kbytes to the page. This effects the loading of the page in the client.
放个dategrid,load 点数据,postback,然后看sourcecode,viewstate占了90-99%,也就是说viewstate把页面变大了10倍到100倍,关这个点够头痛了
it is passed as plain text to the client. Anybody can tamper this value, because of this you shouldnt store any important data in the viewstate.
View state is one of the most important features of ASP.NET, not so much because of its technical relevance, but more because it makes the magic of the Web Forms model possible.
However, if used carelessly, view state can easily become a burden. Although ViewState is freely accessible in a hidden field called __VIEWSTATE, the view state information is not clear text. By default, a machine-specific authentication code is calculated on the data and appended to the view state string. The resulting text is then Base64 encoded only, but not encrypted. In order to make the view state more secure, the ASP.NET @Page directive supports an attribute called EnableViewStateMac whose only purpose is detecting any possible attempt at corrupting original data.更多精彩文章及讨论,请光临枫下论坛 rolia.net