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