Developer on Alibaba Coud: Build your first app with APIs, SDKs, and tutorials on the Alibaba Cloud. Read more ＞
It is actually using the file "global. asa "! Many new ASP programmers want to know what this is? In fact, global. asa is an event driver, which contains four event processing processes: Application_OnStart, Application_OnEnd, Session_OnStart, and Session_OnEnd.
When a page of an application on a website is accessed by a user for the first time, global. asa is loaded into the memory. When the application starts or ends, or the session starts or ends, you can add the script code to be executed.
With some tips, you can use the global. asa file to schedule tasks.
Here is an example: "Tracking the number of visitors to a website; when the number of visits reaches 100, the counter is reset to 0 and the code you prepared is executed ". Of course, you can adjust the maximum number of visits to 100 based on your needs.
The contents of global. asa are as follows:
<Script language = VBScript RUNAT = Server>
Application ("SessionCount") = 0
Application ("SessionCount") = Application ("SessionCount") + 1
If Application ("SessionCount")> 100 Then
Application ("SessionCount") = 0
'Here you wocould put any code you need to run
'Do not surround the code with <%> tags
'For example you might run a database query that checks for expired accounts
Next, let's take a look at the execution of a task four times a day. You can store the date and time values in a text file and periodically check it. When the last six hours of time, write the new date and time to the text file and start the task you want to execute. You can change the value of "6" to execute more or less tasks.
Although the above method requires read and write permissions on text files before it can be correctly executed, it is still a very smart solution!
In this routine, the text file is checked once every 15 new visitors. Of course, you can adjust the value of "15" or set to check the text file whenever there are new visitors. However, such processing will undoubtedly increase the load on the site and waste server resources! In short, the inspection frequency is determined by yourself.
In this example, the validity of the date and time when a text file is written for the first time must be ensured. Otherwise, a running error occurs when the program reads a null value for the first time.
This article is an English version of an article which is originally in the Chinese language on aliyun.com and is provided for information purposes only. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or
reliability of the article or any translations thereof. If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or
complaint, to email@example.com. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.
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:
and provide relevant evidence. A staff member will contact you within 5 working days.