473,382 Members | 1,362 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,382 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 4282
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...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.