Click to See Complete Forum and Search --> : Can't write to file from Global.asa


huebi
09-21-2004, 01:46 AM
I have trouble writing from global.asa

my code looks like this

Sub Application_OnStart
Application("pathinfo")=Server.MapPath("test.txt")
End Sub

Sub Session_OnEnd
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile(Application("pathinfo"),2)
f.WriteLine("Text written by global.asa")
f.Close
set f=Nothing
set fs=Nothing
End Sub

I don't get any errors, but the the .txt file is not written to.
What am I doing wrong?

Thanks in advance

buntine
09-21-2004, 06:51 AM
Are you certain the code is executing when it supposed to? The session will most likely not expire until the users session has not been altered for 20 minutes. Unless you have changed the default server settings.

Regards.

huebi
09-21-2004, 07:12 AM
Yes, Session_OnEnd does fire, i reduced the posted code to problem.
I count active session with
Application("active")=Application("active")+1
in the OnStart event and
Application("active")=Application("active")-1
in the OnEnd event and it works fine.
In order to test the code i have set
Session.Timeout=1
I can write perfectly to files from .asp pages, but not from global.asa. I also checked permissions