B
Bonj
Hi
I have an ASP.NET application which implements a server-side charting
solution, for this it needs to generate .gif files which are then sent to
the browser via a literal which has its text set to "<img src=\" +
graphfilename + \"/>. This is all working beautifully, however all these
..gif files are going to build up on the server and are going to need
deleting. I tried putting some code in the Session_End function in
global.asax, but Session_End *NEVER* fires. (I proved this to be the case
because I put some code to write to a log file on Session_Start,
Session_End, Application_Start and Application_End. After a couple of days,
the *_End ones never logged once, but there were about 5 Application_Starts
(which I presume represent the first time it started after a rebuild?) and a
load of Session_Starts). This is the case no matter whether a debug build or
release build is done.
Short of creating a bot that will be scheduled to run every 24 hours to
delete all old files, how can I delete all the files as soon as possible,
but after they are needed?
I tried putting Response.Flush() and then deleting the file after that, but
the browser doesn't then get the image. I'm tempted to try creating a new
thread that waits for a few seconds, deletes the file, then dies. But this
sounds messy as I don't know how good an idea it is to create an extra
thread from a code-behind in an IIS application, what with IIS obviously
being extremely multithreaded itself intrinsically.
Given that Session_End never fires, what would be the best way to delete
files as and when they are used, but making sure that the browser has had
chance to pick them up?
Or would the bot be a better solution ? I'd certainly be happy with that,
although if there is cleaner solution I'd like to know what it is in order
to implement that instead.#
I have an ASP.NET application which implements a server-side charting
solution, for this it needs to generate .gif files which are then sent to
the browser via a literal which has its text set to "<img src=\" +
graphfilename + \"/>. This is all working beautifully, however all these
..gif files are going to build up on the server and are going to need
deleting. I tried putting some code in the Session_End function in
global.asax, but Session_End *NEVER* fires. (I proved this to be the case
because I put some code to write to a log file on Session_Start,
Session_End, Application_Start and Application_End. After a couple of days,
the *_End ones never logged once, but there were about 5 Application_Starts
(which I presume represent the first time it started after a rebuild?) and a
load of Session_Starts). This is the case no matter whether a debug build or
release build is done.
Short of creating a bot that will be scheduled to run every 24 hours to
delete all old files, how can I delete all the files as soon as possible,
but after they are needed?
I tried putting Response.Flush() and then deleting the file after that, but
the browser doesn't then get the image. I'm tempted to try creating a new
thread that waits for a few seconds, deletes the file, then dies. But this
sounds messy as I don't know how good an idea it is to create an extra
thread from a code-behind in an IIS application, what with IIS obviously
being extremely multithreaded itself intrinsically.
Given that Session_End never fires, what would be the best way to delete
files as and when they are used, but making sure that the browser has had
chance to pick them up?
Or would the bot be a better solution ? I'd certainly be happy with that,
although if there is cleaner solution I'd like to know what it is in order
to implement that instead.#