J
Jorge_Beteta
Hi experts!
This is a difficult question.
How to delete temporary files when the user leaves the web page? Is it
possible to do it with .NET? I'm starting to think it is not.
I have WebPage1.aspx. It will make some temporay files (*.gif or
*.jpg). What I need is when the user leaves WebPage1.aspx, temporary
files have to be deleted.
I try Javascript, using window.unOnload event. unOnload event will
call a Logout.aspx that will delete the temporary files using:
File.Delete("c:/Inetpub/wwwroot/temp/.gif").
'On WebPage1.aspx
<Script language="javascript">
function endSession()
{
window.open( "http://ServerName/Logout.aspx");
}
</Script>
<body onUnload="endSession()">
'On Logout.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
File.Delete("c:\Inetpub\wwwroot\temp\*.tmp")
End Sub
However, on every SUBMIT of WebPage1.aspx, it will raise
window.onUnload, which means
File.Delete("c:/Inetpub/wwwroot/temp/*.gif") will be executed on every
SUBMIT as well. But I just need it be executed when the user leaves
the page.
As you can notice, I just want to delete temporary files on a
directory when the user leaves the web page. Is it so difficult with
..NET?
Thanks a lot!
This is a difficult question.
How to delete temporary files when the user leaves the web page? Is it
possible to do it with .NET? I'm starting to think it is not.
I have WebPage1.aspx. It will make some temporay files (*.gif or
*.jpg). What I need is when the user leaves WebPage1.aspx, temporary
files have to be deleted.
I try Javascript, using window.unOnload event. unOnload event will
call a Logout.aspx that will delete the temporary files using:
File.Delete("c:/Inetpub/wwwroot/temp/.gif").
'On WebPage1.aspx
<Script language="javascript">
function endSession()
{
window.open( "http://ServerName/Logout.aspx");
}
</Script>
<body onUnload="endSession()">
'On Logout.aspx
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
File.Delete("c:\Inetpub\wwwroot\temp\*.tmp")
End Sub
However, on every SUBMIT of WebPage1.aspx, it will raise
window.onUnload, which means
File.Delete("c:/Inetpub/wwwroot/temp/*.gif") will be executed on every
SUBMIT as well. But I just need it be executed when the user leaves
the page.
As you can notice, I just want to delete temporary files on a
directory when the user leaves the web page. Is it so difficult with
..NET?
Thanks a lot!