473,769 Members | 6,267 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session_End Event does not Fire.

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 points,
writes to a database table, and writes to a text file to indicate when this
event fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but nothing
happens when this event is supposed to fire. I really do need this so
information would be hugely appreciated.

ERJ MCSD MCDBA.

Nov 19 '05 #1
11 2826
1) How are you sure that the session has indeed timed out?
2) Are you sure whatever code you have in Session_End isn't failing due to a
coding error?
3) Show us the code you have for your Session_End handler

"OldProgram mer" <Ol***********@ discussions.mic rosoft.com> wrote in message
news:95******** *************** ***********@mic rosoft.com...
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
points,
writes to a database table, and writes to a text file to indicate when
this
event fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but
nothing
happens when this event is supposed to fire. I really do need this so
information would be hugely appreciated.

ERJ MCSD MCDBA.

Nov 19 '05 #2
OldProgrammer wrote:
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 points, writes to a
database table, and writes to a text file to indicate when this event
fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but
nothing happens when this event is supposed to fire. I really do
need this so information would be hugely appreciated.

ERJ MCSD MCDBA.


You didn't specify, but when do you expect the Session_End to
occur? It's 20 minutes (by default) after the last request for this
session, not (as a lot of people assume) as soon as the browser
closes or the user "navigates away".

Hans Kesting
Nov 19 '05 #3
On top of that setting a breakpoint won't work. .NET connects to the web app
and listens to what it's doing in order to hit breakpoints. I believe that
will keep the session open.

I would set a write to a database/text file inside of the session end
handler, set your session time out to one minute (or less), compile the
application, connect to it manually outside of .NET
(http://localhost/yourappnamehere), and then step away for a water or soda.
When you come back the write should have occurred.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:e%******** ********@TK2MSF TNGP12.phx.gbl. ..
OldProgrammer wrote:
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 points, writes to a
database table, and writes to a text file to indicate when this event
fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but
nothing happens when this event is supposed to fire. I really do
need this so information would be hugely appreciated.

ERJ MCSD MCDBA.


You didn't specify, but when do you expect the Session_End to
occur? It's 20 minutes (by default) after the last request for this
session, not (as a lot of people assume) as soon as the browser
closes or the user "navigates away".

Hans Kesting

Nov 19 '05 #4
The original question specifies
1. First tried to run needed code, then
2. Tried to write to dB table (hardcoding all connection strings and
values), then
3. writing to a plain vanilla text file.
4. I tried setting the web.config file to show time out value of 2 minutes.
Then when that did not work reset it back to 20 minutes and waited one hour.
All the seesion variables are gone and the application behaves as it is
supposed to when the session variables have been lost. The only thing that
did not happen was the write to the DB table then text file.

So I know the session did time out.
"S. Justin Gengo" wrote:
On top of that setting a breakpoint won't work. .NET connects to the web app
and listens to what it's doing in order to hit breakpoints. I believe that
will keep the session open.

I would set a write to a database/text file inside of the session end
handler, set your session time out to one minute (or less), compile the
application, connect to it manually outside of .NET
(http://localhost/yourappnamehere), and then step away for a water or soda.
When you come back the write should have occurred.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:e%******** ********@TK2MSF TNGP12.phx.gbl. ..
OldProgrammer wrote:
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 points, writes to a
database table, and writes to a text file to indicate when this event
fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but
nothing happens when this event is supposed to fire. I really do
need this so information would be hugely appreciated.

ERJ MCSD MCDBA.


You didn't specify, but when do you expect the Session_End to
occur? It's 20 minutes (by default) after the last request for this
session, not (as a lot of people assume) as soon as the browser
closes or the user "navigates away".

Hans Kesting


Nov 19 '05 #5

I tried setting the web.config file to show time out value of 2 minutes.
Then when that did not work reset it back to 20 minutes and waited one hour.
All the seesion variables are gone and the application behaves as it is
supposed to when the session variables have been lost. The only thing that
did not happen was the write to the DB table then text file.

So I know the session did time out.

"Hans Kesting" wrote:
OldProgrammer wrote:
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 points, writes to a
database table, and writes to a text file to indicate when this event
fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but
nothing happens when this event is supposed to fire. I really do
need this so information would be hugely appreciated.

ERJ MCSD MCDBA.


You didn't specify, but when do you expect the Session_End to
occur? It's 20 minutes (by default) after the last request for this
session, not (as a lot of people assume) as soon as the browser
closes or the user "navigates away".

Hans Kesting

Nov 19 '05 #6
1. The Web config was changed to show timeout at 2 minutes. When this did
not work, It was changed back to 20 minutes. Then I waited One hour before
clicking on the page. All Session variables were lost and all code behaved
as designed to do when session variables have been lost.

2. I used simplest possible database code, when I got no writes to the
table used below code in that event. In both cases, the code was run
elsewhere on a different page to verify that it was running with out errors
and it worked. I have not seen anything stating that ADO.Net or streamwriter
does work in Session_End. I am also using virtually same code in methods of
global.asax called from Session start event. All code runs properly without
issue.
Here is Session_end event code.

Dim swObject As StreamWriter 'Text Stream Object
Dim sPath As String

sPath = Server.MapPath( "testClose.txt" )

swObject = File.CreateText (sPath)
swObject.Write( "closing" & CStr(Now()))
swObject = Nothing

ERJ MCSD MCDBA

"Marina" wrote:
1) How are you sure that the session has indeed timed out?
2) Are you sure whatever code you have in Session_End isn't failing due to a
coding error?
3) Show us the code you have for your Session_End handler

"OldProgram mer" <Ol***********@ discussions.mic rosoft.com> wrote in message
news:95******** *************** ***********@mic rosoft.com...
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
points,
writes to a database table, and writes to a text file to indicate when
this
event fires. So far I have got nothing back. Yet I am able to verify the
the session has timed out. I have no indication of code failure, but
nothing
happens when this event is supposed to fire. I really do need this so
information would be hugely appreciated.

ERJ MCSD MCDBA.


Nov 19 '05 #7
You never actually close the file in your code. Which means it stays open,
and the next time someone else tries to write to it, they get an error.

Neither writing to disk or to the database are the simplest, because there
are so many potential things that could go wrong. With files you could have
a permissions issue, a file could be a readonly, etc. Also, if 2 users have
their sessions expire at the same time, this would cause an error as well.

To easily test Session_End createa variable somewhere that is Shared. Make
it an integer and initialize it to 0. In Session_Start increase it by 1. In
Session_End, decrease it by 1. Make sure to synchronize that code to avoid
threading issues.

Then, you should be able to open like 10 sessions, and then have a page that
writes out the value in that variable, and watch the number decrease as
sessions timeout. Of course, you should always have at least 1 session
alive - the one that you are checking the value with.

"OldProgram mer" <Ol***********@ discussions.mic rosoft.com> wrote in message
news:4C******** *************** ***********@mic rosoft.com...
1. The Web config was changed to show timeout at 2 minutes. When this
did
not work, It was changed back to 20 minutes. Then I waited One hour
before
clicking on the page. All Session variables were lost and all code
behaved
as designed to do when session variables have been lost.

2. I used simplest possible database code, when I got no writes to the
table used below code in that event. In both cases, the code was run
elsewhere on a different page to verify that it was running with out
errors
and it worked. I have not seen anything stating that ADO.Net or
streamwriter
does work in Session_End. I am also using virtually same code in methods
of
global.asax called from Session start event. All code runs properly
without
issue.
Here is Session_end event code.

Dim swObject As StreamWriter 'Text Stream Object
Dim sPath As String

sPath = Server.MapPath( "testClose.txt" )

swObject = File.CreateText (sPath)
swObject.Write( "closing" & CStr(Now()))
swObject = Nothing

ERJ MCSD MCDBA

"Marina" wrote:
1) How are you sure that the session has indeed timed out?
2) Are you sure whatever code you have in Session_End isn't failing due
to a
coding error?
3) Show us the code you have for your Session_End handler

"OldProgram mer" <Ol***********@ discussions.mic rosoft.com> wrote in
message
news:95******** *************** ***********@mic rosoft.com...
> 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
> points,
> writes to a database table, and writes to a text file to indicate when
> this
> event fires. So far I have got nothing back. Yet I am able to verify
> the
> the session has timed out. I have no indication of code failure, but
> nothing
> happens when this event is supposed to fire. I really do need this so
> information would be hugely appreciated.
>
> ERJ MCSD MCDBA.
>


Nov 19 '05 #8
May we see your OnSessionEnd method?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"OldProgram mer" <Ol***********@ discussions.mic rosoft.com> wrote in message
news:63******** *************** ***********@mic rosoft.com...
The original question specifies
1. First tried to run needed code, then
2. Tried to write to dB table (hardcoding all connection strings and
values), then
3. writing to a plain vanilla text file.
4. I tried setting the web.config file to show time out value of 2
minutes.
Then when that did not work reset it back to 20 minutes and waited one
hour.
All the seesion variables are gone and the application behaves as it is
supposed to when the session variables have been lost. The only thing
that
did not happen was the write to the DB table then text file.

So I know the session did time out.
"S. Justin Gengo" wrote:
On top of that setting a breakpoint won't work. .NET connects to the web
app
and listens to what it's doing in order to hit breakpoints. I believe
that
will keep the session open.

I would set a write to a database/text file inside of the session end
handler, set your session time out to one minute (or less), compile the
application, connect to it manually outside of .NET
(http://localhost/yourappnamehere), and then step away for a water or
soda.
When you come back the write should have occurred.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:e%******** ********@TK2MSF TNGP12.phx.gbl. ..
> OldProgrammer wrote:
>> 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 points, writes to a
>> database table, and writes to a text file to indicate when this event
>> fires. So far I have got nothing back. Yet I am able to verify the
>> the session has timed out. I have no indication of code failure, but
>> nothing happens when this event is supposed to fire. I really do
>> need this so information would be hugely appreciated.
>>
>> ERJ MCSD MCDBA.
>
> You didn't specify, but when do you expect the Session_End to
> occur? It's 20 minutes (by default) after the last request for this
> session, not (as a lot of people assume) as soon as the browser
> closes or the user "navigates away".
>
> Hans Kesting
>
>


Nov 19 '05 #9
See above my post 9/19/05 1:25 PST

Here:

Dim swObject As StreamWriter 'Text Stream Object
Dim sPath As String

sPath = Server.MapPath( "testClose.txt" )

swObject = File.CreateText (sPath)
swObject.Write( "closing" & CStr(Now()))
swObject = Nothing
"S. Justin Gengo" wrote:
May we see your OnSessionEnd method?

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"OldProgram mer" <Ol***********@ discussions.mic rosoft.com> wrote in message
news:63******** *************** ***********@mic rosoft.com...
The original question specifies
1. First tried to run needed code, then
2. Tried to write to dB table (hardcoding all connection strings and
values), then
3. writing to a plain vanilla text file.
4. I tried setting the web.config file to show time out value of 2
minutes.
Then when that did not work reset it back to 20 minutes and waited one
hour.
All the seesion variables are gone and the application behaves as it is
supposed to when the session variables have been lost. The only thing
that
did not happen was the write to the DB table then text file.

So I know the session did time out.
"S. Justin Gengo" wrote:
On top of that setting a breakpoint won't work. .NET connects to the web
app
and listens to what it's doing in order to hit breakpoints. I believe
that
will keep the session open.

I would set a write to a database/text file inside of the session end
handler, set your session time out to one minute (or less), compile the
application, connect to it manually outside of .NET
(http://localhost/yourappnamehere), and then step away for a water or
soda.
When you come back the write should have occurred.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Hans Kesting" <ne***********@ spamgourmet.com > wrote in message
news:e%******** ********@TK2MSF TNGP12.phx.gbl. ..
> OldProgrammer wrote:
>> 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 points, writes to a
>> database table, and writes to a text file to indicate when this event
>> fires. So far I have got nothing back. Yet I am able to verify the
>> the session has timed out. I have no indication of code failure, but
>> nothing happens when this event is supposed to fire. I really do
>> need this so information would be hugely appreciated.
>>
>> ERJ MCSD MCDBA.
>
> You didn't specify, but when do you expect the Session_End to
> occur? It's 20 minutes (by default) after the last request for this
> session, not (as a lot of people assume) as soon as the browser
> closes or the user "navigates away".
>
> Hans Kesting
>
>


Nov 19 '05 #10

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

Similar topics

9
10803
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();
3
1650
by: Mark Field | last post by:
Assuming that IIS is not restared, and that the web server is not restarted, should the "session_end" event in the global file ALWAYS fire or will there be times when it will not fire? protected void Session_End(Object sender, EventArgs e) { }
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
3113
by: news.microsoft.com | last post by:
For some odd reason, session start fires but session_end does not. I am running the web server inproc, the web.config is configured as: <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="true" timeout="1"
3
1610
by: MattB | last post by:
Hi. I have a couple of questions regarding the Session_End event. I have some clean-up code in this event and it does fire when the session times out, which is good. I also want to have this (or similar) code fire when the session ends prematurely, like when the browser window is closed or Session.Clear is called. It appears that does not happen, but is there any way I can force it or is there a different event that would fire in these...
7
1753
by: T. | last post by:
Does the Session_End event actually fire? I am building an ASP.NET application, and so far I have an HTML page and a single asp page. The HTML is the home page. I have code in the Global.asax file's Session_End handler that closes the session's connections to the SQL backend. The thing never fires! After my app closes, I run sp_who in Query Analyzer to see connections to the database. Low and behold my ASP connections are still there! What...
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...
12
10698
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...
5
2764
by: Ron J | last post by:
I would like to keep track of users when they are 'on'. On Session_Start I can write a DB record about them, but there does not seem to be session variable information during the Session_end event which I could use to update the record that they are logged out. This would also be nice to limit multiple logins. Is there a preferred way to track users login / logout /session time and multiple logins ? TIA
0
9589
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
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9994
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
9863
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...
1
7409
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5299
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...
1
3959
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
2
3562
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.