Asp.net page parameter Period

Source: Internet
Author: User

 

The viewstate lifecycle is from the beginning to the end of a single page.

 

 

 

Method

Information size

Save time

Application Scope

Save location

Application

Any size

Entire application life cycle

All users

Server

Session

Small amount, simple data

User Activity time + a delay (generally 20 minutes)

Single User

Server

Cookie

Small amount, simple data

Can be set as needed

Single User

Client

1. Application Object
Application is used to save the public data information of all users. If the application object is used, a problem to be considered is that any write operation must be performed on the application_onstart event (Global. asax. although application. lock and applicaiton. the unlock method is used to avoid synchronization of write operations. However, it serializes the requests to the application object. When the site traffic is large, it will produce a serious performance bottleneck. therefore, it is best not to use this object to store large data sets.

2. Session Object
Session is used to save the dedicated information of each user. her survival time is the user's continuous request time plus a period of time (usually about 20 minutes ). the session information is stored in the web server content. The stored data volume can be large or small. the stored data is automatically released when the session times out or is disabled. because the user stops using the application and it remains in the memory for a period of time, the session object is used to save user data very efficiently. for a small amount of data, it is a good choice to use the session object to save. the code for saving information using the session object is as follows:

// Store information
Session ["username"] = "zhouhuan ";
// Read data
String username = session ["username"]. tostring ();

3. Cookie object
Cookie is used to save the request information of the client browser request Server Page. programmers can also use it to store non-sensitive user information. The time for saving the information can be set as needed. if no cookie expiration date is set, they are only saved until the browser program is closed. if the expires attribute of the cookie object is set to minvalue, the cookie will never expire. the amount of data stored in cookies is very limited. Most browsers support a maximum capacity of 4096. Therefore, do not store datasets and other large amounts of data. since not all browsers support cookies and data information is stored in plain text on the client's computer, it is best not to store sensitive, unencrypted data, otherwise, the website security will be affected. the code for saving the cookie object is as follows:

// Store information
Response. Cookies ["userid"]. value = "0001 ";
// Read information
String userid = response. Cookies ["userid"]. value;
Related Article

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.