Home All Groups Group Topic Archive Search About

Session_OnEnd does not DeleteFile()



Author
26 Feb 2005 5:38 PM
andrea azzini
I've got an ASP3 (IIS6) site, in which some scripts need to generate
temporary files in order to work. Now, the fact is: I would like those
temporary files to be deleted when a user's session ends (even though i've
got infinite hosting space, i feel it somewhat impolite to leave GB's of
useless temp files ;-) ).

The Session_OnEnd event, though, seems to have some problems in doing this:

1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
problem, I hardcoded the base path and everything should have worked well.
2. The FileSystemObject.DeleteFile() method, though, seems to suffer from
the same problem: i get no error output on Session.Abandon() but the files
are still there.

Is there any workaround for this problem?
Thanks in advance
Andrea Azzini

Author
26 Feb 2005 6:24 PM
Bob Barrows [MVP]
andrea azzini wrote:
Show quote
> I've got an ASP3 (IIS6) site, in which some scripts need to generate
> temporary files in order to work. Now, the fact is: I would like those
> temporary files to be deleted when a user's session ends (even though
> i've got infinite hosting space, i feel it somewhat impolite to leave
> GB's of useless temp files ;-) ).
>
> The Session_OnEnd event, though, seems to have some problems in doing
> this:
>
> 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
> problem, I hardcoded the base path and everything should have worked
> well.
> 2. The FileSystemObject.DeleteFile() method, though, seems to suffer
> from the same problem: i get no error output on Session.Abandon() but
> the files are still there.
>
> Is there any workaround for this problem?
> Thanks in advance
> Andrea Azzini

Your IWAM_machinename account needs Change permissions for the folder.
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Author
26 Feb 2005 6:50 PM
andrea azzini
ehp... not possible... i mean, have an hosting plan so i can't access the
server's system settings. But ASP scripts have full access permissions to
that specific folder.


Show quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> ha scritto nel messaggio
news:%23ioi5BDHFHA.2276@TK2MSFTNGP15.phx.gbl...
> andrea azzini wrote:
> > I've got an ASP3 (IIS6) site, in which some scripts need to generate
> > temporary files in order to work. Now, the fact is: I would like those
> > temporary files to be deleted when a user's session ends (even though
> > i've got infinite hosting space, i feel it somewhat impolite to leave
> > GB's of useless temp files ;-) ).
> >
> > The Session_OnEnd event, though, seems to have some problems in doing
> > this:
> >
> > 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
> > problem, I hardcoded the base path and everything should have worked
> > well.
> > 2. The FileSystemObject.DeleteFile() method, though, seems to suffer
> > from the same problem: i get no error output on Session.Abandon() but
> > the files are still there.
> >
> > Is there any workaround for this problem?
> > Thanks in advance
> > Andrea Azzini
>
> Your IWAM_machinename account needs Change permissions for the folder.
> Bob Barrows
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
Author
26 Feb 2005 6:55 PM
Bob Barrows [MVP]
Session and Application events run under the IWAM account, not the IUSR.
There is no other solution. IWAM needs file-system permissions for that
folder.

Bob Barrows
andrea azzini wrote:
Show quote
> ehp... not possible... i mean, have an hosting plan so i can't access
> the server's system settings. But ASP scripts have full access
> permissions to that specific folder.
>
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> ha scritto nel
> messaggio news:%23ioi5BDHFHA.2276@TK2MSFTNGP15.phx.gbl...
>> andrea azzini wrote:
>>> I've got an ASP3 (IIS6) site, in which some scripts need to generate
>>> temporary files in order to work. Now, the fact is: I would like
>>> those temporary files to be deleted when a user's session ends
>>> (even though i've got infinite hosting space, i feel it somewhat
>>> impolite to leave GB's of useless temp files ;-) ).
>>>
>>> The Session_OnEnd event, though, seems to have some problems in
>>> doing this:
>>>
>>> 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
>>> problem, I hardcoded the base path and everything should have worked
>>> well.
>>> 2. The FileSystemObject.DeleteFile() method, though, seems to suffer
>>> from the same problem: i get no error output on Session.Abandon()
>>> but the files are still there.
>>>
>>> Is there any workaround for this problem?
>>> Thanks in advance
>>> Andrea Azzini
>>
>> Your IWAM_machinename account needs Change permissions for the
>> folder. Bob Barrows
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a quicker response by posting to the newsgroup.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Author
26 Feb 2005 11:26 PM
andrea azzini
No way to get that. But I've found another solution... i'll use a BLOB in
the mysql database where i surely have all the access rights i need. Thanx
anyway.

Show quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> ha scritto nel messaggio
news:%23LxsDTDHFHA.3332@TK2MSFTNGP15.phx.gbl...
> Session and Application events run under the IWAM account, not the IUSR.
> There is no other solution. IWAM needs file-system permissions for that
> folder.
>
> Bob Barrows
> andrea azzini wrote:
> > ehp... not possible... i mean, have an hosting plan so i can't access
> > the server's system settings. But ASP scripts have full access
> > permissions to that specific folder.
> >
> >
> > "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> ha scritto nel
> > messaggio news:%23ioi5BDHFHA.2276@TK2MSFTNGP15.phx.gbl...
> >> andrea azzini wrote:
> >>> I've got an ASP3 (IIS6) site, in which some scripts need to generate
> >>> temporary files in order to work. Now, the fact is: I would like
> >>> those temporary files to be deleted when a user's session ends
> >>> (even though i've got infinite hosting space, i feel it somewhat
> >>> impolite to leave GB's of useless temp files ;-) ).
> >>>
> >>> The Session_OnEnd event, though, seems to have some problems in
> >>> doing this:
> >>>
> >>> 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
> >>> problem, I hardcoded the base path and everything should have worked
> >>> well.
> >>> 2. The FileSystemObject.DeleteFile() method, though, seems to suffer
> >>> from the same problem: i get no error output on Session.Abandon()
> >>> but the files are still there.
> >>>
> >>> Is there any workaround for this problem?
> >>> Thanks in advance
> >>> Andrea Azzini
> >>
> >> Your IWAM_machinename account needs Change permissions for the
> >> folder. Bob Barrows
> >>
> >> --
> >> Microsoft MVP -- ASP/ASP.NET
> >> Please reply to the newsgroup. The email account listed in my From
> >> header is my spam trap, so I don't check it very often. You will get
> >> a quicker response by posting to the newsgroup.
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
Author
27 Feb 2005 10:12 AM
Roland Hall
"andrea azzini" <andyl***@andylong.cjb.net> wrote in message
news:XA7Ud.52831$lB4.1433367@twister1.libero.it...
: No way to get that. But I've found another solution... i'll use a BLOB in
: the mysql database where i surely have all the access rights i need. Thanx
: anyway.

Can you say performance hit?  I chose a different path for cleanup.  I wrote
a routine the merchant runs once a day.  It cleans up all temp files 3 days
or older, or whatever their retention setting is.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Author
27 Feb 2005 2:55 PM
andrea azzini
This sounds really interesting, i had not thought about it... but, is there
any way to have a script run at an aribitrary time or should i just put it
into another (frequently accessed) page and let it check whether it's time
to run or not?
Remember i am on hosting so i can't do more than edit the files in my site's
directory...


Show quote
"Roland Hall" <nobody@nowhere> ha scritto nel messaggio
news:%23BzTNTLHFHA.580@TK2MSFTNGP15.phx.gbl...
> "andrea azzini" <andyl***@andylong.cjb.net> wrote in message
> news:XA7Ud.52831$lB4.1433367@twister1.libero.it...
> : No way to get that. But I've found another solution... i'll use a BLOB
in
> : the mysql database where i surely have all the access rights i need.
Thanx
> : anyway.
>
> Can you say performance hit?  I chose a different path for cleanup.  I
wrote
> a routine the merchant runs once a day.  It cleans up all temp files 3
days
> or older, or whatever their retention setting is.
>
> --
> Roland Hall
> /* This information is distributed in the hope that it will be useful, but
> without any warranty; without even the implied warranty of merchantability
> or fitness for a particular purpose. */
> Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
> WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
Show quote
Author
27 Feb 2005 4:57 PM
Aaron [SQL Server MVP]
> This sounds really interesting, i had not thought about it... but, is there
> any way to have a script run at an aribitrary time or should i just put it
> into another (frequently accessed) page and let it check whether it's time
> to run or not?

I think there are web-based cron-type services out there that will allow you
to schedule hits against your URLs from their remote servers.  You can also
see http://www.aspfaq.com/2143
Author
28 Feb 2005 1:33 PM
Roland Hall
"andrea azzini" wrote in message
news:vblUd.53852$QG6.973817@twister2.libero.it...
: This sounds really interesting, i had not thought about it... but, is
there
: any way to have a script run at an aribitrary time or should i just put it
: into another (frequently accessed) page and let it check whether it's time
: to run or not?
: Remember i am on hosting so i can't do more than edit the files in my
site's
: directory...

I didn't look at Aaron's link but if you cannot get it scheduled, I looked
at it this way.  My customer has a menu for administration.  This is
separate than maintenance.  Administration has two functions.

1. Get orders
2. Cleanup

Get orders will show a list of all order files and they can be viewed,
printed and archived.
Cleanup cleans up all temporary files in the orders file directory that are
3 days or older, based on a value in the config file.
I inform them to run a cleanup at least once when getting orders.  My
shopping cart cleans up files when orders are complete and only leaves
successful order files.  I cannot determine if someone fails to complete a
shopping experience but I can try to do cleanup with Session_OnEnd.  I found
several issues with that approach.  So, I chose to just make a generic
routine that cleans up the files.  There are 2 files left if the order is
not completed for each shopper.  50 shoppers = 100 files.  They are single
digit k byte XML files.  100 files would be less than 1mb.  This is only for
unprocessed orders and they are only created if someone leaves something in
their shopping cart and either leaves the site, closes their browser or
times out.

I also didn't want to clean them automatically in case someone was having
trouble and called support.  This would give the support person something to
look at so the order could be completed on the phone.

For those who host their own sites, I can offer an automated cleanup, if
desired.  Nobody yet has requested this process be automatic since cleanup
takes care of it and only takes seconds at the most.

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Author
26 Apr 2005 11:32 AM
Propin
Have the same problem, IWAM_machinename did not solve my problem. Have
created the following test code (file is never deleted on my IIS6 Win2003
environment, any idea?):

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

Sub Application_OnStart

End Sub

Sub Session_OnStart

Set objFileSystemObject = Server.CreateObject("Scripting.FilesystemObject")


objFileSystemObject.CreateTextFile "C:\temp\error\Test.txt", True

Set objFileSystemObject = Nothing


End Sub

Sub Session_OnEnd


Set objFileSystemObject = Server.CreateObject("Scripting.FilesystemObject")


objFileSystemObject.CreateTextFile "C:\temp\error\Test.txt", True

Set objFileSystemObject = Nothing

End Sub

Sub Application_OnEnd

End Sub

</SCRIPT>

/Propin





Show quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:%23ioi5BDHFHA.2276@TK2MSFTNGP15.phx.gbl...
> andrea azzini wrote:
>> I've got an ASP3 (IIS6) site, in which some scripts need to generate
>> temporary files in order to work. Now, the fact is: I would like those
>> temporary files to be deleted when a user's session ends (even though
>> i've got infinite hosting space, i feel it somewhat impolite to leave
>> GB's of useless temp files ;-) ).
>>
>> The Session_OnEnd event, though, seems to have some problems in doing
>> this:
>>
>> 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
>> problem, I hardcoded the base path and everything should have worked
>> well.
>> 2. The FileSystemObject.DeleteFile() method, though, seems to suffer
>> from the same problem: i get no error output on Session.Abandon() but
>> the files are still there.
>>
>> Is there any workaround for this problem?
>> Thanks in advance
>> Andrea Azzini
>
> Your IWAM_machinename account needs Change permissions for the folder.
> Bob Barrows
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
Author
27 Feb 2005 3:31 AM
Aaron [SQL Server MVP]
I'll echo what Bob said.
See http://www.aspfaq.com/2078


On 2/26/05 12:38 PM, in article Ju2Ud.52792$QG6.950***@twister2.libero.it,
Show quote
"andrea azzini" <andyl***@andylong.cjb.net> wrote:

> I've got an ASP3 (IIS6) site, in which some scripts need to generate
> temporary files in order to work. Now, the fact is: I would like those
> temporary files to be deleted when a user's session ends (even though i've
> got infinite hosting space, i feel it somewhat impolite to leave GB's of
> useless temp files ;-) ).
>
> The Session_OnEnd event, though, seems to have some problems in doing this:
>
> 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
> problem, I hardcoded the base path and everything should have worked well.
> 2. The FileSystemObject.DeleteFile() method, though, seems to suffer from
> the same problem: i get no error output on Session.Abandon() but the files
> are still there.
>
> Is there any workaround for this problem?
> Thanks in advance
> Andrea Azzini
>
>
Author
27 Feb 2005 2:57 PM
andrea azzini
This also clarifies some question i had wondered about the difference
between those two users on my testing server... thank you.


Show quote
"Aaron [SQL Server MVP]" <ten.xoc@dnartreb.noraa> ha scritto nel messaggio
news:BE46A924.1557%ten.xoc@dnartreb.noraa...
> I'll echo what Bob said.
> See http://www.aspfaq.com/2078
>
>
> On 2/26/05 12:38 PM, in article Ju2Ud.52792$QG6.950***@twister2.libero.it,
> "andrea azzini" <andyl***@andylong.cjb.net> wrote:
>
> > I've got an ASP3 (IIS6) site, in which some scripts need to generate
> > temporary files in order to work. Now, the fact is: I would like those
> > temporary files to be deleted when a user's session ends (even though
i've
> > got infinite hosting space, i feel it somewhat impolite to leave GB's of
> > useless temp files ;-) ).
> >
> > The Session_OnEnd event, though, seems to have some problems in doing
this:
> >
> > 1. I found in MSDN that it couldn't call Server.MapPath(). Not a big
> > problem, I hardcoded the base path and everything should have worked
well.
> > 2. The FileSystemObject.DeleteFile() method, though, seems to suffer
from
> > the same problem: i get no error output on Session.Abandon() but the
files
> > are still there.
> >
> > Is there any workaround for this problem?
> > Thanks in advance
> > Andrea Azzini
> >
> >
>

AddThis Social Bookmark Button