Viewstate in ASP. NET

Source: Internet
Author: User

I have been doing some operations based on. net web application performance testing, the test tool often records the hidden attribute _ viewstate, and often finds that this attribute has some problems in "association, the request may fail. Sometimes the value of this attribute is very long. For example, it exceeds 2000 bytes and is repeated in the script over and over again, seriously affecting the readability of the script.

Therefore. in config, the topic is disabled, but it does not take a deep look at what this topic is, why it appears, and what effect it has on the authenticity of the test.

Today is a bit blank. I found an authoritative document and learned about it.

ASP. NET viewstateHttp://www.microsoft.com/china/community/program/originalarticles/techdoc/viewstate.mspx

Below is a summary.

-------------- Begin ---------------

Viewstate is a mechanism that ASP. NET uses to track the status values of server controls. Otherwise, these values are not returned as part of the HTTP form.
ASP. NET viewstate is a new State service that allows developers to track the UI state based on each user. Viewstate is nothing mysterious. It only uses an old web programming technique to pass the State back and forth in a hidden form field.
By default, viewstate is enabled, and the content stored in viewstate is determined by each control (rather than page developers. Sometimes, this information applies to applicationsProgramIt is useless. Although there is no harm, it will significantly increase the size of the page sent to the browser. Therefore, if you do not need to use viewstate, you 'd better disable it, especially when the viewstate is large.

When viewstate is used, each object must be first serialized to viewstate, and then deserialized through callback. Therefore, viewstate is not a cost-effective method.
Disable viewstate -- application (in Web. config): <pages enableviewstate = "false "? />
If viewstate is not mandatory in an application and a large viewstate is automatically generated to affect the performance, disable it.

-------------- End ---------------

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.