About cache, viewstate, session, application, static variables

Source: Internet
Author: User

Cache, viewstate, session, application, static variable
 
In ASP. the classes used for cross-page storage and data transfer in. NET are listed in the titles. Today, due to an incorrect understanding of the cache scope in a website, this leads to overtime, so I wrote a smallProgramTest them.

I wrote a small program to test these programs and found that:

Session and viewstate are all page-level variables, that is, each client corresponds to a different instance, and operations between them will not affect each other. viewstate is used only for a page. It is very similar to the following static variables. Only objects that can be serialized can be placed in viewstate. Note this when writing classes by yourself!
Application, cache, and static are all application-level variables. That is to say, no matter how many users are connected to the entire web site, this instance is shared. no matter who performs the operation, other users may get the wrong result.
Static is different from the other two. Application and cache can be accessed no matter which page you are on, while static only works when declaring its page! If you declare that the httphandler class is implemented, and all the pages inherit from the class you write, there is almost no difference with the application!

Because the cache is only suitable for storing application-level configuration information!
 


Source: http://spaces.msn.com/members/yan0lovesha/Blog/cns! 1pgx6lwe44bxcf3ndw5asbqg! 127. Entry

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.