473,770 Members | 5,977 Online
Bytes | Software Development & Data Engineering Community
+ 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 4329
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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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*******@disc ussions.microso ft.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******** *****@TK2MSFTNG P12.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.Cur rent.Session.Ab andon(). 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***@somewher e.nl> wrote in message
news:40******** *************** @news.wanadoo.n l...
"Alvin Bruney" <vapor at steaming post office> wrote in message
news:ef******** *****@TK2MSFTNG P12.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.Cur rent.Session.Ab andon(). 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.Cur rent.User). After I started checking for null with
HttpContext.Cur rent 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***@somewher e.nl> wrote in message
news:40******** *************** @news.euronet.n l...
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.Cur rent.User). After I started checking for null with
HttpContext.Cur rent 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
11391
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 Session_Start. Now my question is Why is it that the Session_End is never fired. I was forced to...
9
10804
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
4733
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 use this variable on a web form to show current users online. All of this works just fine, so 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 wondering if there are there well-known/documented circumstances under which Session_End will NOT fire...
4
9181
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 the meaning of Session_End if you don't know which session is
7
1643
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 with these settings in my web.config file. I'm using <authentication mode="Windows" /> and <identity...
11
2827
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 writing, I have been unable discern any indication that the event is firing. I have used break...
8
5770
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 dispose of objects? Or is there an event I can you that is fired when a user navigates away from...
1
6940
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 the database just as I would expect. Nonetheless, an exception is being generated by the code...
12
10700
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 to use the Session_End() event in Global.asax even though I know that this will only occur once the...
0
9592
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10005
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9871
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8887
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5313
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.