473,499 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session_OnEnd does not DeleteFile()

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
Jul 22 '05 #1
11 1807
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.
Jul 22 '05 #2
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]" <re******@NOyahoo.SPAMcom> ha scritto nel messaggio
news:%2****************@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.

Jul 22 '05 #3
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]" <re******@NOyahoo.SPAMcom> ha scritto nel
messaggio news:%2****************@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.
Jul 22 '05 #4
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.

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel messaggio
news:%2****************@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]" <re******@NOyahoo.SPAMcom> ha scritto nel
messaggio news:%2****************@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.

Jul 22 '05 #5
I'll echo what Bob said.
See http://www.aspfaq.com/2078
On 2/26/05 12:38 PM, in article Ju********************@twister2.libero.it,
"andrea azzini" <an******@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


Jul 22 '05 #6
"andrea azzini" <an******@andylong.cjb.net> wrote in message
news:XA*********************@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
Jul 22 '05 #7
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...
"Roland Hall" <nobody@nowhere> ha scritto nel messaggio
news:%2***************@TK2MSFTNGP15.phx.gbl...
"andrea azzini" <an******@andylong.cjb.net> wrote in message
news:XA*********************@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

Jul 22 '05 #8
This also clarifies some question i had wondered about the difference
between those two users on my testing server... thank you.
"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> ha scritto nel messaggio
news:BE46A924.1557%te*****@dnartreb.noraa...
I'll echo what Bob said.
See http://www.aspfaq.com/2078
On 2/26/05 12:38 PM, in article Ju********************@twister2.libero.it,
"andrea azzini" <an******@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

Jul 22 '05 #9
> 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

Jul 22 '05 #10
"andrea azzini" wrote in message
news:vb********************@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
Jul 22 '05 #11
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

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@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.

Jul 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3045
by: Tom Bates | last post by:
I can successfully delete files using fso.DeleteFile when in an ASP script. But in Session_OnEnd, where I'd *really* like to clean up files, it appears that DeleteFile doesn't work. I've tried...
1
2455
by: Soha El-Saeed | last post by:
Dear All; I wrote this code in the global.asa but it dosen't work inspite that it works in any asp file and also in the global.asa file but only in the session_onstart part.This code is to delete...
3
3685
by: cab | last post by:
i have the following code in the "Sub Session_OnEnd" routine that does not seem to run..... Sub Session_OnEnd strConnect = "Driver={SQL Server};Server=SERVER;Database=database; User...
24
2422
by: Nancy Drew | last post by:
hi all i'm trying to keep users from being able to login to a site twice at the same time. everytime a user does a login, i stick their userID into an application scoped array. if they try to...
4
6761
by: Propin | last post by:
Have a problem with below code in global.asa. Same problem as described in this news group before, IWAM_machinename did not solve my problem. Have created the following test code (file is never...
4
2552
by: anand | last post by:
In my website i want to trace the event when user log off from the site by closing the explorer so i am unable to run any server side program at that time and my session_onend event also not...
1
2123
by: Andy Kasotia | last post by:
My Session_OnStart works but Session_OnEnd does not work. Here's the code...can anyone tell me what's wrong with my code or if anything else on the server that needs to be changed. The...
4
3701
by: rbt | last post by:
Can someone detail the differences between these two? On Windows which is preferred? Also, is it true that win32api.DeleteFile() can remove the 'special' files located in the 'special' folders...
11
2070
by: David Thielen | last post by:
Hi; Is there some kind of session ID variable that I can get in the code behind and that is available in Session_OnEnd() to know what session ended? -- thanks - dave...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3090
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.