Problems with my global.asa

Results 1 to 2 of 2

Thread: Problems with my global.asa

  1. #1
    Join Date
    Dec 1969

    Default Problems with my global.asa

    I&#039m having terrible problems with my global.asa. It appears as though the OnEnd sections (both Application and Session) aren&#039t being called.<BR><BR>Am I doing something wrong? Please help! Here&#039s the relevant code (a counter and an e-mail generator) that doesn&#039t seem to work:<BR><BR>Sub Application_OnStart<BR> &#039 Compute our count file<BR> Application("strCountFileName") = Server.MapPath("pagecount.txt")<BR> &#039 Create FileSystemObject to deal with file access<BR> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR> &#039 Open the file as a text stream (1 = ForReading, True = Create)<BR> Set objCountFile = objFSO.OpenTextFile(Application("strCountFileName" ), 1, True)<BR><BR> &#039 Read the current count from the file<BR> If Not objCountFile.AtEndOfStream Then<BR> &#039 Set value to contents of the file<BR> Application("iCount") = CLng(objCountFile.ReadAll)<BR> Else<BR> &#039 If no file exists or it&#039s empty start at 0<BR> Application("iCount") = 0<BR> End If<BR><BR> &#039 Close the file and destroy the object<BR> objCountFile.Close<BR> Set objCountFile = Nothing<BR>End Sub<BR>Sub Application_OnEnd<BR> &#039 Overwrite existing file and get a text stream to new one<BR> Set objCountFile = objFSO.CreateTextFile(Application("strCountFileNam e"), True)<BR><BR> &#039 Write updated count<BR> objCountFile.Write Application("iCount")<BR><BR> &#039 Close the file and destroy the object<BR> objCountFile.Close<BR> Set objCountFile = Nothing<BR><BR><BR> &#039 Destroy the FSO object<BR> Set objFSO = Nothing<BR>End Sub<BR>Sub Session_OnStart<BR> &#039 Increment the count<BR> Application.Lock<BR> Application("iCount") = Application("iCount") + 1<BR> Application.Unlock<BR> Session("strFileName") = Server.MapPath("_private") & "\" & Session.SessionID & ".txt"<BR>End Sub<BR>Sub Session_OnEnd<BR> Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR> Set objOpenFile = objFSO.OpenTextFile(Session("strFileName"), 1)<BR> objOpenFile.ReadAll = strBody<BR> objOpenFile.Close<BR> Set objOpenFile = Nothing<BR> objFSO.DeleteFile Session("strFileName"), True<BR> Set objFSO = Nothing<BR> Set objCDOMail = Server.CreateObject("CDONTS.NewMail")<BR> objCDOMail.From = "e-mail address"<BR> objCDOMail.To = ""<BR> objCDOMail.Subject = "Information Request"<BR> objCDOMail.Body = strBody<BR> objCDOMail.Send<BR> Set objCDOMail = Nothing<BR>End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: Problems with my global.asa

    onend doesn&#039t fire consistently I&#039m afraid. you&#039ll need to find an alternative method<BR><BR>j

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts