Session object, application object, and viewstate object

Source: Internet
Author: User
Session object, application object, and viewstate object are important objects of ASP. NET. They can be used to save application data or cache webpage data. However, they still have the following differences.
1. The session object and Application object are global. After the entire application is running, the program can access the session object and Application object at any time; after a viewstate object is assigned a value on a specific page, when the page is closed, other pages of the application cannot use the corresponding value of the viewstate object.

2. The session object is exclusive to one user, not shared by all users accessing the site. Each access user has its own unique sessionid, and the session object is always valid before the application. It is functionally similar to static variables. The viewstate object can be seen as a local variable of a page.

3. The application object is shared by all users on the site. Each access user can access the application object. In the development of some common forums, you can use the application object to count the number of online user visits, and use the session object to count the total number of visits.

4. The extensive use of viewstate objects can increase the overhead of applications. If you need to consider program efficiency, be especially careful when using viewstate objects.

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.