Hi Rod,
Sorry for my late response. I have been way too busy with work to be able to respond to any e-mail or posts here.
Anyway, yes, I think it will. Of IIS I am sure. The whole idea of Application_OnEnd is that it fires when IIS gets restarted or stopped. This means that if you shut down the machine, start and stop or restart IIS, Application_OnEnd will fire.
When you make a change to the Global.asa, both the Application and the existing Sessions are ended. For a quick test, create a Web site and add this code to the global.asa:
Code:
<script language="vbscript" runat="server">
Const openForReading = 1
Const openForWriting = 2
Const openForAppending = 8
Dim fso, f
Dim txtStream, fileName
fileName = "C:\Test.txt"
Sub Application_OnEnd()
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(fileName)
Set txtStream = f.OpenAsTextStream(openForAppending)
' Append lines to the file
txtStream.WriteLine "App End"
txtStream.Close
Set txtStream = Nothing
Set f = Nothing
Set fso = Nothing
End Sub
Sub Session_OnEnd()
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(fileName)
Set txtStream = f.OpenAsTextStream(openForAppending)
' Append lines to the file
txtStream.WriteLine "Session End"
txtStream.Close
Set txtStream = Nothing
Set f = Nothing
Set fso = Nothing
End Sub
</script>
Create an empty text document called C:\Test.txt (the code assumes it's present).
Next, create a simple page with this code:
Code:
<%
If Session("Test") = "" Then
Session("Test") = Now()
End If
Response.Write(Session("Test"))
%>
Run the page to start the session. Refresh the page a couple of times and you'll notice the time stays the same (because the session is still alive).
Next, open the global.asa file, add a line break at the top of the page (to make the page dirty) and save the file. Next, refresh the page in your browser again. You'll notice the time will change because the Session has ended.
Finally, open C:\Test.txt. You'll find both Session_OnEnd as Application_OnEnd has fired.
Now, all that is left to figure out is whether an Anti Virus program actually "dirties" the file global.asa, causing the behavior described above to occur. I'll leave this quest to the readers of this thread, and go back to work now ;)
Cheers,
Imar