Do not abuse ViewState

Source: Internet
Author: User

ASP. NET provides the ViewState feature to store page-level state information. This is a good thing (I personally think ), however, even abuse of good things can cause serious consequences! In the lifecycle of a Page, the ViewState is loaded and saved, and sent to the customer and the customer for submission to the server. When ViewState processes many and complex things, it will lead to energy and data transmission pressure (I heard ASP. NET 2.0 provides a better way to load and save ViewState ).

Developers who do not know the details of ViewState processing seldom care about this problem. They only know that ViewState is very convenient to use, and do not expect that the program will cause serious problems soon! In reality, a colleague asked me why page processing is slow and why ViewState is so large. So I learned that there are more than one thousand pieces of data on that page, and each GridItem has a DropDownList with dozens of items. Simply calculate that every time you refresh the page, tens of thousands of ListItem data are to be loaded and saved. Needless to say, everyone can think of this efficiency. There are also tens of thousands of listitems and thousands of GridItem data sent to the customer and the customer to submit to the server, it is terrible to have such a large data transfer volume on a common page (more seriously, the ViewState is too large to exceed the default request bytes of IIS ~~)!

There are also some things that developers can think about. Can developers just learn how to use things? However, many developers I know do this!

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.