473,623 Members | 2,453 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 FileSystemObjec t.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 1825
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 FileSystemObjec t.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_machinenam e 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******@NOyah oo.SPAMcom> ha scritto nel messaggio
news:%2******** ********@TK2MSF TNGP15.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 FileSystemObjec t.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_machinenam e 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******@NOyah oo.SPAMcom> ha scritto nel
messaggio news:%2******** ********@TK2MSF TNGP15.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 FileSystemObjec t.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_machinenam e 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******@NOyah oo.SPAMcom> ha scritto nel messaggio
news:%2******** ********@TK2MSF TNGP15.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******@NOyah oo.SPAMcom> ha scritto nel
messaggio news:%2******** ********@TK2MSF TNGP15.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 FileSystemObjec t.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_machinenam e 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************* *******@twister 2.libero.it,
"andrea azzini" <an******@andyl ong.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 FileSystemObjec t.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******@andyl ong.cjb.net> wrote in message
news:XA******** *************@t wister1.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******** *******@TK2MSFT NGP15.phx.gbl.. .
"andrea azzini" <an******@andyl ong.cjb.net> wrote in message
news:XA******** *************@t wister1.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*****@dnartr eb.noraa> ha scritto nel messaggio
news:BE46A924.1 557%te*****@dna rtreb.noraa...
I'll echo what Bob said.
See http://www.aspfaq.com/2078
On 2/26/05 12:38 PM, in article Ju************* *******@twister 2.libero.it,
"andrea azzini" <an******@andyl ong.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 FileSystemObjec t.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

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

Similar topics

3
3060
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 every combination I could think of. I've verified the filespecs I'm using by logging to a session log file. BTW, I found out the hard way that I can't reference Request.ServerVariables("APPL_PHYSICAL_PATH") from within Session_OnEnd. I had to copy...
1
2466
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 a txt file at the end of the session.The file was created during the user's session and has the name of the session id. The session variable "session("mpath")" is the varible which will hold the path of the created file. This is my first question...
3
3703
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 ID=xxxxxx;Pwd=xxxxxxx" Set objConnEnd = Server.CreateObject("ADODB.Connection") objConnEnd.Open strConnect
24
2450
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 login again, i bounce them to an error page. i use the session_onEnd sub within global.asa to remove their userID from the array at the end of their session, and this seems to work fine. however, if i just shut down the browser, the sub_onEnd...
4
6791
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 deleted on my IIS6 Win2003 environment, any idea?): <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> Sub Application_OnStart End Sub
4
2570
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 working can any one tell me why the session_onend is not working. Thanx in advance
1
2132
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 Session_OnStart does create the folder for me with the SessionID as the folder name but Session_OnEnd does not delete that folder. Sub Session_OnStart Dim fso, f, DirToCreate 'Create a folder to store PDF Files Set fso =...
4
3711
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 only accessible by the shell object such as Temporary Internet Files, etc. Thanks!
11
2094
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 david_at_windward_dot_net http://www.windwardreports.com
0
8165
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8670
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8613
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8469
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7150
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6106
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4074
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2602
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 we have to send another system
1
1778
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.