ASP基础入门第九篇(Global.asa文件的使用)

  < SCRIPT LANGUAGE="VBScript" RUNAT="Server">

  'Session_OnStart 当客户首次运行 ASP 应用程序中的任何一个页面时运行

  'Session_OnEnd 当一个客户的会话超时或退出应用程序时运行

  'Application_OnStart 当任何客户首次访问该应用程序的首页时运行

  'Application_OnEnd 当该站点的 WEB 服务器关闭时运行

  < /SCRIPT>

  < SCRIPT LANGUAGE="VBScript" RUNAT="Server">

  Sub Application_OnStart

  VisitorCountFilename = Server.MapPath ("/ex2") + "VisitCount.txt"

  Set FileObject = Server.CreateObject("Scripting.FileSystemObject")

  Set Out= FileObject.OpenTextFile (VisitorCountFilename, 1, FALSE, FALSE)

  Application("visitors") = Out.ReadLine

  Application("VisitorCountFilename") = VisitorCountFilename

  End Sub

  '=========================================================

  SUB Application_OnEnd

  Set FileOutObject = Server.CreateObject("Scripting.FileSystemObject")

  Set Out= FileOutObject.CreateTextFile (Application("VisitorCountFilename"), TRUE,FALSE)

  Out.WriteLine(application("visitors"))

  End Sub

  '=========================================================Sub Session_OnStart

  Session.Timeout = 5

  Application("visitors") = Application("visitors") + 1

  Session("ID")=Session.SessionID

  End Sub

  < /SCRIPT>