In-depth study of Application and Session objects (including global. asa) 1

Source: Internet
Author: User
When using ASP to write virtual communities, online shopping, and other programs, Application and Session objects play an important role. Flexible and rational use of these two objects is the key to improving program quality. The following describes the two built-in ASP objects based on my experience in this area.
1. Application object member overview
Application object members include the set, method, and event of the Application object.
Collections Application object set
Contents set: a set of all variables stored in the Applicaiton OBJECT that are not defined by the <OBJECT> element
StaticObjects: set of all variables stored in the Application OBJECT defined by the <OBJECT> element
For example, the default. asp has the following values:
Application ("a") = ""
Application ("B") = 128
Application ("c") = false
There is a contents set
Application. contents (1) = "a" 'can also be written as application. contents ("a") = ""
Application. contents (2) = 128 'can also be written as application. contents ("B") = 128
Application. contents (3) = false' can also be written as application. contents ("c") = false
We recommend that you use the method such as application. contents ("a") for calling, because it is more intuitive. If you use the serial number to represent it, you should consider the order of values.
Method of using Application object
Contents. Remove ("variable name"): removes the specified variable from the Application. Contents set.
Contents. RemoveAll (): delete all variables in the Application. Contents set.
Lock (): Lock the Application object so that only the current ASP page can access the content
Unlock (): Unlock the Application object
For example, in default. asp:
Application ("a") = ""
Application ("B") = 128
Application ("c") = false
Response. write application. contents (1) & "<br>"
Response. write application. contents (2) & "<br>"
Response. write application. contents (3) & "<br>"
Response. write "After Remove B :"
Application. contents. remove ("B ")
Response. write application. contents (1) & "<br>"
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.