Parsing ASP's application and session objects

Source: Internet
Author: User

In the published series we have discussed two ASP objects: The Application object and the session object, thus having access to the collection, methods, properties, and events provided by the Application object and the Sessions object. This section will study these two objects from the perspective of programming.

· When loading an ASP DLL and responding to the first request for an ASP Web page, create the Application object. This object provides a storage place to store variables and objects that are available to all Web pages that are open to all visitors.

· When the visitor first requests an ASP page from the site, create a session object for him and remain valid until the default time-out period (or the timeout period determined by the script). This object provides a storage place to store variables and objects that are available only to pages that the visitor opens during the session's activity.

Relationship

1, ASP's Application Object member overview

This section describes the collection, methods, and events of the Application object (Application object has no attributes). The Session object (with attributes) is described in the next section. You will then continue to explore the tasks accomplished by using these objects and describe in more detail how each member of each object works.

1. Collection of Application objects

The Application object provides two collections that can be used to access variables and objects stored in the global application space. The collection and description are as follows:

The collection and description of table application objects

Collection Description
Contents A collection of all the variables (and their values) stored in the Application object that are defined by the element is not used. References that include variant arrays and instances of variant type objects
StaticObjects A collection of all the variables (and their values) that are stored in the Application object, as defined by the element

2. Methods of Application objects

The Application object method allows you to delete values in the global application space and control concurrent access to variables within that space. Method and description as shown in the following table:

Method and description of table Application Object

Method Description
Contents.Remove ("Variable_name") To remove a variable named Variable_name from the Application.content collection
Contents.RemoveAll () Remove all variables from the Application.content collection
Lock () Locks the Application object so that only the current ASP page can access the content. A concurrent operation that ensures that two users are allowed to read and modify this value at the same time does not break the content
Unlock () Unlock an ASP Web page on a Application object

Note that you cannot delete a variable from the Application.staticobjects collection during run time.

3. Events for application objects

The Application object provides two events that are triggered when it starts and ends, as shown in the following table:

Events and descriptions for table application objects

Event Description
OnStart Triggered when ASP starts, before the Web page that the user requests is executed and before any user creates the Session object. For initializing variables, creating objects, or running other code
OnEnd Triggered when an ASP application is finished. Occurs after the last user session has ended and all the code in the OnEnd event of the session has been executed. When it ends, all variables present in the application are canceled
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.