1. ViewState is not the value of the control used to recover postbacks.
This is done automatically by matching the variable name of the control in form. This is valid only for controls that were created before the Load event was loaded.
2. ViewState does not automatically re-create any controls that are created dynamically through code.
3. is not used to hold user information. Simply save the control state on this page and not pass between pages.
What is
ViewState?
ViewState is used to track and save state information for controls. Otherwise, this information may be lost because the values do not return with the form or are not in page HTML at all.
The
ViewState holds the changed control properties in the code, binds to any data of the control through code, and any changes that are triggered by user actions and postback.
ViewState also provides a status pack (StateBag), a special set or dictionary (collection or dictionary) that can be used to save and recover arbitrary objects or values through a key.
ViewState Format
the __viewstate hidden field that is saved in the form. It's Base64 encoded, not encrypted!
But it is also possible to encrypt (set enableViewStateMac to use machine key for hashing)
encryption: Set MachineKey authentication, but this must be set at the machine level and requires more resources, so it is not recommended.
Listing 1:viewstate Machine Hash Disabled
Machine.config or web.config: <pages enableviewstatemac= ' false '/>
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.