473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Session_End

Hi..,

I tried to execute some code in the Sub Session_End in
the Global.asax, but its not working.
I am developing the asp.net application on Windows Server
2003 and IIS6. Tell me whats the problem.

Imran
Nov 18 '05 #1
7 4277
How do you know it's not working? Session_End will fire at the end of a User
Session, but it may not be firing when you expect it to. Sessions usually
end by timing out from lack of Requests, and the default time-out period for
Sessions is, I believe, 20 minutes. In addition, if you're debugging, of
course the Session_End will not fire if you stop debugging.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Imran" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi..,

I tried to execute some code in the Sub Session_End in
the Global.asax, but its not working.
I am developing the asp.net application on Windows Server
2003 and IIS6. Tell me whats the problem.

Imran

Nov 18 '05 #2
"Imran" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I tried to execute some code in the Sub Session_End in
the Global.asax, but its not working.

Depends on what you mean by "not working". If you have out-of process
session state, you won't receive Session_End.

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com
Nov 18 '05 #3
see this article for a full discussion on session_end event
http://tinyurl.com/2t7gq

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Imran" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi..,

I tried to execute some code in the Sub Session_End in
the Global.asax, but its not working.
I am developing the asp.net application on Windows Server
2003 and IIS6. Tell me whats the problem.

Imran

Nov 18 '05 #4
"Alvin Bruney" <vapor at steaming post office> wrote in message
news:ef*************@TK2MSFTNGP12.phx.gbl...
see this article for a full discussion on session_end event
http://tinyurl.com/2t7gq


I came across a couple of these articles all saying the same thing. It
sounds very credible but when I try it, it just appears it doesn't work that
way. Maybe something broke since version 1.1 of the .NET Framework or it is
not the whole story. I am using mode=InProc, I do put the current date in a
session variable from the Page_Load event, I post back the form by clicking
a button and execute HttpContext.Current.Session.Abandon(). No Session_End
event.

I tested the code I put in Session_End separately before pasting it in
(since it is supposed to fail silently on errors when the session expires).
It just doesn't fire, Session_End is one big lie in ASP.NET.

Martin.
Nov 18 '05 #5
post a complete working example demonstrating the problem. I will take a
look at it.

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Martin" <du***@somewhere.nl> wrote in message
news:40***********************@news.wanadoo.nl...
"Alvin Bruney" <vapor at steaming post office> wrote in message
news:ef*************@TK2MSFTNGP12.phx.gbl...
see this article for a full discussion on session_end event
http://tinyurl.com/2t7gq
I came across a couple of these articles all saying the same thing. It
sounds very credible but when I try it, it just appears it doesn't work

that way. Maybe something broke since version 1.1 of the .NET Framework or it is not the whole story. I am using mode=InProc, I do put the current date in a session variable from the Page_Load event, I post back the form by clicking a button and execute HttpContext.Current.Session.Abandon(). No Session_End
event.

I tested the code I put in Session_End separately before pasting it in
(since it is supposed to fail silently on errors when the session expires). It just doesn't fire, Session_End is one big lie in ASP.NET.

Martin.

Nov 18 '05 #6
Alvin,
It just doesn't fire, Session_End is one big lie in ASP.NET.
post a complete working example demonstrating the problem.
I will take a look at it.


That is very nice. However, I've been at it all day and I found what the
problem was.

After making a small project in Visual Studio I found that to work just
fine. Then it was a matter of finding the differences between my hand-made
project and the little thing that Visual Studio spit up. And there were a
lot of differences...

I finally discovered that my test code that was called from several
application events to help me see the sequence of events failed silently. It
messed with the User object and although I was being a good boy doing

if (User == null) ...

before accessing any members, this still was the code that broke it all.
User is not available at all times (since it is really
HttpContext.Current.User). After I started checking for null with
HttpContext.Current it was okay.

So these silent errors in one or more application events prevented ASP.NET
from finishing some sequence and setting some hooks, causing Session_End not
to be fired later on.
Now had I started doing my project from within Visual Studio from the start
I might have hit the error straight away in the debugger (or maybe not, I
don't know how and if the debugger hooks up with application events). It
doesn't seem too hard to wrap a Visual Studio project around my site, I will
probably do so soon now that I felt how much time I can spend finding
something silly as this.

Thanks for the insights. I did learn a lot in the process. I still feel
stupid though, now why would that be :-).

Martin.
Nov 18 '05 #7
phew!!!, that was a nasty one. thanks for keeping us informed. i'm sure it
will help somebody else later.

--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Martin" <du***@somewhere.nl> wrote in message
news:40***********************@news.euronet.nl...
Alvin,
It just doesn't fire, Session_End is one big lie in ASP.NET.
post a complete working example demonstrating the problem.
I will take a look at it.


That is very nice. However, I've been at it all day and I found what the
problem was.

After making a small project in Visual Studio I found that to work just
fine. Then it was a matter of finding the differences between my hand-made
project and the little thing that Visual Studio spit up. And there were a
lot of differences...

I finally discovered that my test code that was called from several
application events to help me see the sequence of events failed silently.

It messed with the User object and although I was being a good boy doing

if (User == null) ...

before accessing any members, this still was the code that broke it all.
User is not available at all times (since it is really
HttpContext.Current.User). After I started checking for null with
HttpContext.Current it was okay.

So these silent errors in one or more application events prevented ASP.NET
from finishing some sequence and setting some hooks, causing Session_End not to be fired later on.
Now had I started doing my project from within Visual Studio from the start I might have hit the error straight away in the debugger (or maybe not, I
don't know how and if the debugger hooks up with application events). It
doesn't seem too hard to wrap a Visual Studio project around my site, I will probably do so soon now that I felt how much time I can spend finding
something silly as this.

Thanks for the insights. I did learn a lot in the process. I still feel
stupid though, now why would that be :-).

Martin.

Nov 18 '05 #8

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

Similar topics

2
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...
9
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; ...
2
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....
3
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...
4
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...
7
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...
11
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...
8
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....
1
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...
12
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.