473,549 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session_End?

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_Sta rt and Application_End . After a couple of days,
the *_End ones never logged once, but there were about 5 Application_Sta rts
(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.#

Nov 18 '05 #1
2 2371
I have used Session_End before and it worked. This is curious.

Can you post a sample of how you were doing your testing?

Is it possible the code caused an error which would not be logged, then
abandoned the session?
"Bonj" <a@b.com> wrote in message
news:e6******** *****@TK2MSFTNG P11.phx.gbl...
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_Sta rt and Application_End . After a couple of days, the *_End ones never logged once, but there were about 5 Application_Sta rts (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.#

Nov 18 '05 #2
Can you post a sample of how you were doing your testing

//This is in global.asax
protected void Session_End(Obj ect sender, EventArgs e

LogToText("Sess ion ended")
protected void LogToText(strin g message

System.IO.Strea mWriter sw = new StreamWriter(Se rver.MapPath(@" tempcharts\logf ile.txt"), true)
message += " " + DateTime.Now.To String()
if((User != null) && (User.Identity != null)) message += " (user = " + User.Identity.N ame + ")"
sw.WriteLine(me ssage)
sw.Close()
Is it possible the code caused an error which would not be logged, the
abandoned the session

No, it wasn't erroring. I put exactly the same function call in Session_Start and Application_Sta rt only passing a different string, and that worked fine

I think I'll go for a daily bot. Never mind

"Bonj" <a@b.com> wrote in messag
news:e6******** *****@TK2MSFTNG P11.phx.gbl..
H
I have an ASP.NET application which implements a server-side chartin
solution, for this it needs to generate .gif files which are then sent t
the browser via a literal which has its text set to "<img src=\"
graphfilename + \"/>. This is all working beautifully, however all thes
.gif files are going to build up on the server and are going to nee
deleting. I tried putting some code in the Session_End function i
global.asax, but Session_End *NEVER* fires. (I proved this to be the cas
because I put some code to write to a log file on Session_Start
Session_End, Application_Sta rt and Application_End . After a couple o days the *_End ones never logged once, but there were about Application_Sta rt (which I presume represent the first time it started after a rebuild?) an load of Session_Starts) . This is the case no matter whether a debug buil o release build is done
Short of creating a bot that will be scheduled to run every 24 hours t 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 bu the browser doesn't then get the image. I'm tempted to try creating a ne
thread that waits for a few seconds, deletes the file, then dies. But thi
sounds messy as I don't know how good an idea it is to create an extr
thread from a code-behind in an IIS application, what with IIS obviousl
being extremely multithreaded itself intrinsically
Given that Session_End never fires, what would be the best way to delet
files as and when they are used, but making sure that the browser has ha
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 orde
to implement that instead.

Nov 18 '05 #3

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

Similar topics

2
11379
by: Chris Sibel | last post by:
Hey guys I have a user tracking setup to track users. What it does is once a user hits my site it sends me an email telling me some info and once a user clicks the logout button it sends a second email that tells me what pages the visited, how long they were on each page, etc. The second email is in the Session_End Sub and the first is in the...
9
10796
by: Kenn Ghannon | last post by:
I've got an ASP.NET page with a counter subtraction routine in the Session_End method in the Global.asax.cs: protected void Session_End(Object sender, EventArgs e) { ulong curUsers; Application.Lock();
2
4719
by: Bela | last post by:
Hello I was wondering if someone could help me out with a Session_End problem in my Global.asax. I've tried everything, and still no success Here is the scenario: sessionstate is set to InProc. I have timeout set to 1 min I have a variable in session_start that is incremented each new session, and it is then decremented in Session_End. I...
3
566
by: Guadala Harry | last post by:
Just wondering if Session_End *always fires* for every Session. I know that IIS times out sessions after a default 20 min (unless changed) and there's no way to know when a user actually closed a browser (unless I provide a "log out" button that kills the session explicitly, and we can't guarantee the user will click on that). What I am...
4
9163
by: Kim Bach Petersen | last post by:
I would like to record user behavior data stored in session variables. Since the data is modified throughout each session it seemed obvious to store the data when the session terminates - using Session_End in global.asax. Problem is, apparently the session-object terminating cannot be accessed from Session_End in global.asax!? What's...
7
1637
by: Henry | last post by:
I have a question on session_end. I'm trying to log into my database when the session times out, it will store user info into a table. When I got step into a line where I was trying to open connection (I had it set to timeout in 1 minute, and ran it in debug mode), nothing happens. I read somewhere before about how database call can't work...
11
2808
by: OldProgrammer | last post by:
All the documentation and discussion I have read indicate that the Session_End is not supposed to fire unless you are in "inProc" Session state mode, and then only on Session Timeout or at Session Abandon. I need the event to fire at Session timeout in order to capture and store the Datetime this occurs. However in the application I am...
8
5765
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning. But, when a user either navigates away from the web app and when the session timesout, the session_end event does not seem to fire. Or when else can I...
1
6908
by: =?Utf-8?B?YnJlbnQ5NjA=?= | last post by:
Environment: ASP.NET 2.0, SQL Server 2005, C#, Visual Studio 2005 In my Session_End event, I am executing a stored procedure to update a database table that is used to log user sessions. When the user sessions time out, the Session_End event fires successfully. The stored procedure executes successfully, and I can see the updated data in...
12
10651
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they manually log OUT of the site, I have no problem deleting them from the PeopleOnline table. But if they just close the browser, I was assuming I'd have...
0
7467
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...
1
7500
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7827
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...
0
6066
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...
0
5110
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3494
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1961
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
1079
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.