ASP global. Asa instructions for use

Source: Internet
Author: User

/* ------------------- ASP document reference set -----------------------*/
* --> Author: Crawler
* --> Time: 2007-4.28---2007-4.30)
* --> Contact: caolvchong@gmail.com
* --> Document function:
1. I reviewed ASP and deepened my understanding of ASP structure and ASP experience.
2. It can be used for ASP reference and self-written for reference.

This is Part 4: Global. asa

/* --------------------------- About ASP components ------------------------*/
ASP components are not described. When important components (mainly third-party components), such as uploading components
Introduction
/* = ======================================= */

/* ----------------------- Global. Asa -------------------------*/
. ASA is the suffix of the file. It is the abbreviation of active server application. The global. Asa file can be
Manage two very demanding objects in ASP applications: Application and session
Global. ASA is an optional file,ProgramThe writer can specify the event script in the file and declare that a session and
Objects in the application scope. The content of this file is not used to display to users, but to store event information and
The global objects used by the application. The file must be stored in the root directory of the application. Each application can have only one
Global. ASA files
The most common concept of errors with regard to the global. Asa file is that it can be used as a library for general functions and subprograms. The global. Asa file can only be used to create object reference and capture startup, and end application and session objects.
The global. Asa file is accessed Based on session-level events and called in the following three cases:
1. When application_onstart or application_onend event is triggered.
2. When the session_onstart or session_onend event is triggered.
3. When referencing an object that is instantiated in the global. Asa file ).

The standard File Format of Global. ASA is as follows:
<Script language = "VBScript" runat = "server">
Sub application_onstart
'Application _ onstart is run when any customer accesses the homepage of the application for the first time.
End sub

Sub session_onstart
'Session _ onstart: run when the customer runs any page of ASP application for the first time
End sub

Sub session_onend
'Session _ onend when a client's session times out or exits the application
End sub

Sub application_onend
'Application _ onend: run when the website's Web server is closed
End sub
</SCRIPT>

Two classic examples of global. Asa:
1. Force access to the home page, that is, if you access the website for the first time, force access to the Home Page:
<Script language = "VBScript" runat = "server">
Sub session_onstart
Response. Redirect ("Homepage Address ")
End sub
</SCRIPT>

2. Online website statistics:
<Script language = "VBScript" runat = "server">
Sub application_onstart
'When the server is enabled, set the user counter to 0.
Application ("activeusers") = 0
End sub

sub session_onstart
'sets the validity period of the session object to 20 minutes (or longer, but the longer the session object is,
' the more resources are occupied, because the server does not accept a valid time of less than 20 minutes, it is invalid to set a valid time of less than 20
')
session. timeout = 20
'add 1 to the user counter when a session starts.
application. lock
application ("activeusers") = Application ("activeusers") + 1
application. unlock
end sub
sub session_onend
'when a session ends, the user counter is reduced by 1
application. lock
application ("activeusers") = Application ("activeusers")-1
application. unlock
end sub

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.