ASP Application_OnStart ºÍ Application_OnEnd ʼþ
¶¨ÒåºÍÓ÷¨
Application_OnStart ʼþ
Application_OnStart ʼþ·¢ÉúÔÚµÚÒ»¸öеĻỰ´´½¨Ö®Ç° (µ± Application ¶ÔÏóµÚÒ»´Î±»ÒýÓÃʱ)¡£
´Ëʼþ·ÅÖÃÔÚ Global.asa ÎļþÖС£
×¢ÊÍ£ºÔÚ Application_OnStart ʼþ½Å±¾ÖÐÒýÓà Session¡¢Request »òÕß Response ¶ÔÏó»áÒý·¢´íÎó¡£
Application_OnEnd ʼþ
Application_OnEnd ʼþ·¢ÉúÔÚÓ¦ÓóÌÐò½áÊøÊ± (µ± web ·þÎñÆ÷Í£Ö¹ÔËÐÐʱ)¡£
´Ëʼþ·ÅÖÃÔÚ Global.asa ÎļþÖС£
×¢ÊÍ£ºMapPath ·½·¨ÎÞ·¨ÓÃÓÚ Application_OnEnd ´úÂëÖС£
Óï·¨
<script language="vbscript" runat="server"> Sub Application_OnStart . . . End Sub Sub Application_OnEnd . . . End Sub </script>
ʵÀý
Global.asa:
<script language="vbscript" runat="server"> Sub Application_OnEnd() Application("totvisitors")=Application("visitors") End Sub Sub Application_OnStart Application("visitors")=0 End Sub Sub Session_OnStart Application.Lock Application("visitors")=Application("visitors")+1 Application.UnLock End Sub Sub Session_OnEnd Application.Lock Application("visitors")=Application("visitors")-1 Application.UnLock End Sub </script>
ÔÚ ASP ÎļþÖÐÏÔʾµ±Ç°·ÃÎÊÕßµÄÊýÄ¿£º
<html> <head> </head> <body> <p> There are <%response.write(Application("visitors"))%> online now! </p> </body> </html>