Steve,
I have set the session timeout to 2 mins, however my
files dont get deleted. I tried the code in my webform and
it deleted the file. Here is my web.config session tag:
<sessionState mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="2"/>
Here is the code I used:
Sub Session_End(ByVal sender As Object, ByVal e As
EventArgs)
' Fires when the session ends
' Do we have any PDF created?
If Not Session("PDFReportFileName") Is Nothing Then
Dim arFileNames As ArrayList = Session
("PDFReportFileName")
Dim iFile As Integer = 0
For iFile = 0 To arFileNames.Count - 1
Dim strFileName As String = arFileNames
(iFile)
System.IO.File.Delete(Server.MapPath
(strFileName))
Next
End If
End Sub
Thanks for your help
-----Original Message-----
Well, Session_End is certainly the easiest appraoch.
However, you may be able to take advantage of the client
side OnClose event.Here's more info:
http://www.mozilla.org/docs/dom/domr...indow_ref56.ht
ml
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Anonymous" <an*******@discussions.microsoft.com> wrote
in messagenews:08****************************@phx.gbl... Thanks Steve,
now I am wondering if it makes sense to delete the
file in Session_End. Isnt there a way to detect if the
browser was closed? I would like to delete the file immediately
when the browser is closed.
Thanks
-----Original Message-----
Session_End is called (by default) 20 minutes after the
user's last pagerequest.
It has nothing to do with when then user closes their
browser window(s).Therefore your code probably works, just not as quickly
as you'd thought itwould.
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"anonmous" <an*******@discussions.microsoft.com> wrote
in messagenews:10****************************@phx.gbl.. .
Hello,
I am creating a pdf via some code. Now when the pdf
is created, I assign the filename to a session variable
and open a new window with the pdf. Now when the user
closes the pdf window, I would like to delete the file. I was
thinking to check for the session variable in the
global.asax.vb in the session_end. However when I
close the pdf the session_end is never called. Is there any
way to do that?
Thanks in advance
.
.