473,493 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4293
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
11372
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
10789
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
4712
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
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...
4
9154
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
1633
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
2801
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
5758
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
6890
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
10628
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
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6980
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...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6862
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...
0
7364
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...
0
5452
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,...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
282
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...

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.