Performance Comparison of viewstate in ASP. net1.1 and ASP. net2.0

Source: Internet
Author: User

In ASP. net1.1, to improve performance, I believe many programmers will close viewstate on the page, but the benefits of viewstate are self-evident. Fortunately, ASP. net2.0 has greatly improved viewstate performance. Next, let's make a simple experiment. At the same time, we have only one calendar control on the ASP. net1.1 page and ASP. net2.0 page. After the page is loaded, compare the value of viewstate:
ASP. net1.1:
Ddwtmtg1ndkwmjc0nzs7pl12vfm8r/3kar2g84154cbwth7u

ASP. net2.0:
/Wepdwullteznjg5mjaxmzhkzm3popw3dbraqefygzi077prcrtt

Why is ASP. net2.0 longer than ASP. net1.1? Don't worry. Check the value changes after PostBack:
ASP. net1.1:
Ddwtmtg1ndkwmjc0nzt0pdtspgk8mt47pjtsphq8o2w8atwxpjs +
O2w8ddxamdxwpha8bdxtrds + o2w8bdxtexn0zw0urgf0zvr
Pbwusig1zy29ybglilcbwzxjzaw9upteumc41mdawljasien
1bhr1cmu9bmv1dhjhbcwguhvibgljs2v5vg9rzw49yjc3ytvj
Ntyxotm0zta4otwymda2lta3ltezpjs + oz4 + oz47ozs7ozs7
Ozs7pjs7pjs + PJs + 9 eokiaze + 12gw74bc8stbzya2k4 =

ASP. net2.0:
/Wepdwullteznjg5mjaxmzgpzbycagmpzbycageppcsacgeadx
Ychgjtrbybbgcalgndemgizgrk9ch1ooefjno + 6uh0iki2sfshcu =

Obviously, the viewstate value in 2.0 is much smaller than that in 1.0, which greatly improves the performance. The reason is simple. In 1.1, losformatter is used to serialize viewstate data, while in 2.0, a dedicated class objectstateformatter is used to serialize and deserialize viewstate data. Losformatter uses textwriter, while objectstateformatter uses binarywriter, so that bytes is used in 2.0 to keep viewstate rather than string as in 1.1. For example, an integer variable requires four bytes of viewstate data in 1.1, and only one byte in 2.0.

For more information about objectstateformatter, see:
Http://msdn2.microsoft.com/zh-cn/library/system.web.ui.objectstateformatter.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.