473,405 Members | 2,287 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,405 software developers and data experts.

Capturing Session End...

Howdy,

I'm trying to capture the session end event. I put a spot of code in the
Session_End event in the Global.asax.vb file. The function simply writes to
a database table logging the event. I have the same function in the
Session_Begin and the Application events. I am capturing the Session
beginning and the App begin and end but no Session end. My end goal is to
capture some session objects before it dies and log it.

Thanks,

David Lozzi

Oct 1 '07 #1
7 2945
"David Lozzi" <dl****@nospam.nospamwrote in message
news:DC**********************************@microsof t.com...
I'm trying to capture the session end event. I put a spot of code in the
Session_End event in the Global.asax.vb file. The function simply writes
to a database table logging the event. I have the same function in the
Session_Begin and the Application events. I am capturing the Session
beginning and the App begin and end but no Session end. My end goal is to
capture some session objects before it dies and log it.
1) What are you using for session management? If you're not using inproc
sessions, Session_End won't fire...

2) Are you certain there isn't an error in your Session_End code...?

3) Are you absolutely certain that Session_End isn't firing...? How are you
calling it? Obviously, Session_End doesn't fire when you close the client
browser - you have to make it happen manually, or let it happen
automatically when the session eventually times out...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 1 '07 #2
On Oct 1, 7:58 pm, "David Lozzi" <dlo...@nospam.nospamwrote:
Howdy,

I'm trying to capture the session end event. I put a spot of code in the
Session_End event in the Global.asax.vb file. The function simply writes to
a database table logging the event. I have the same function in the
Session_Begin and the Application events. I am capturing the Session
beginning and the App begin and end but no Session end. My end goal is to
capture some session objects before it dies and log it.

Thanks,

David Lozzi
http://groups.google.com/group/micro...&q=session_end

Oct 1 '07 #3
The difference between Sesssion_Begin and Session_End is that
Response/Request objects available in first event and null in another event.

so show us a code and do not say it's the same.....

George.
"David Lozzi" <dl****@nospam.nospamwrote in message
news:DC**********************************@microsof t.com...
Howdy,

I'm trying to capture the session end event. I put a spot of code in the
Session_End event in the Global.asax.vb file. The function simply writes
to a database table logging the event. I have the same function in the
Session_Begin and the Application events. I am capturing the Session
beginning and the App begin and end but no Session end. My end goal is to
capture some session objects before it dies and log it.

Thanks,

David Lozzi

Oct 1 '07 #4
Hi Mark,

1. Using SQL.
2. I am as sure as I can be. See script below
3. I'm assuming it will occur when it times out.

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
common.SessionLog(3)
End Sub

Public Shared Function SessionLog(ByVal LogType As Integer)
Dim ID As String = ""
Dim Parts As String = ""
Dim SessionID As String = ""
Dim customer As String = ""
Dim email As String = ""

Dim uniSession As UniSession = Nothing
Try
Select Case LogType
Case 1
' Application Start
email = "admin"
ID = LogType & "_AppStart_" & IConvD2(Now) & "_" &
IConvMTS(Now) & "_" & CompanyCode
Case 2
' Session Start
SessionID = Current.Session.SessionID.ToString
ID = LogType & "_SessStart_" & SessionID & "_" &
IConvD2(Now) & "_" & IConvMTS(Now) & "_" & CompanyCode
Case 3
' Session End
SessionID = Current.Session.SessionID.ToString
customer = Current.Session("CustomerNum")
email = Current.Session("CustomerEmail")
Dim bag As ArrayList = Current.Session("ShoppingBag")
For Each i As BagItem In bag
Parts &= i.PartNo & "-" & i.Name & " :: "
Next
ID = LogType & "_SessEnd_" & SessionID & "_" &
IConvD2(Now) & "_" & IConvMTS(Now) & "_" & CompanyCode

Case 4
' Application End
email = "admin"
ID = LogType & "_AppEnd_" & IConvD2(Now) & "_" &
IConvMTS(Now) & "_" & CompanyCode
End Select

uniSession = UOOpenSession()

Dim uf As UniFile = uniSession.CreateUniFile("BAG")
With uf
.RecordID = ID
.WriteField(1, Now)
.WriteField(2, Current.Session.SessionID)
.WriteField(3, CompanyCode)
.WriteField(4, Parts)
.WriteField(5, Current.Session("CustomerEmail"))
.WriteField(6, customer)
.Close()
End With
Return True
Catch ex As Exception
UOCloseSession(uniSession)
Dim msg As New MailMessage
msg.From = New
MailAddress(ConfigurationManager.AppSettings("Erro rEmailFrom"))

Dim toEmails() As String =
ConfigurationManager.AppSettings("ErrorEmailTo").S plit(";")
For i As Integer = 0 To toEmails.Length - 1
msg.To.Add(toEmails(i))
Next

msg.Subject = "Error on " &
Current.Request.ServerVariables("SERVER_NAME") & " Website"
msg.IsBodyHtml = True

msg.Body = "<font face=verdana size='2'><b>Error on " &
Current.Request.ServerVariables("SERVER_NAME") & " Website!</b><br>" & Now()
& "<BR><br>" & _
"<b>Page Name:</b>common.vb<br>" & _
"<b>URL:</b>" &
Current.Request.ServerVariables("URL") & "<br>" & _
"<b>Function Name:</bSessionLog<br><br>" & _
"<b>Error Message:</b" & ex.ToString
Dim smtpClient As New SmtpClient
smtpClient.Host = ConfigurationManager.AppSettings("SMTPServer")
smtpClient.Send(msg)
Return False
Finally
UOCloseSession(uniSession)
End Try

End Function

"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:eq**************@TK2MSFTNGP06.phx.gbl...
"David Lozzi" <dl****@nospam.nospamwrote in message
news:DC**********************************@microsof t.com...
>I'm trying to capture the session end event. I put a spot of code in the
Session_End event in the Global.asax.vb file. The function simply writes
to a database table logging the event. I have the same function in the
Session_Begin and the Application events. I am capturing the Session
beginning and the App begin and end but no Session end. My end goal is to
capture some session objects before it dies and log it.

1) What are you using for session management? If you're not using inproc
sessions, Session_End won't fire...

2) Are you certain there isn't an error in your Session_End code...?

3) Are you absolutely certain that Session_End isn't firing...? How are
you calling it? Obviously, Session_End doesn't fire when you close the
client browser - you have to make it happen manually, or let it happen
automatically when the session eventually times out...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Oct 2 '07 #5
"David Lozzi" <dl****@nospam.nospamwrote in message
news:65**********************************@microsof t.com...
>1) What are you using for session management? If you're not using inproc
sessions, Session_End won't fire...
1. Using SQL.
Don't need to look any further than that, then...

Session_End() only fires for inproc sessions...

This hasn't changed since the last time you asked... :-)
http://www.thescripts.com/forum/thread574994.html
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 2 '07 #6
D'OH -- I thought I asked this once before.... Well, then, this is
embarassing...

What are my options then? I need to capture an abandoned session's objects.
Also, how does a session never end when it's on SQL? Or does it and it
doesn't tell IIS/Web site about it?

Thanks,
"Mark Rae [MVP]" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
"David Lozzi" <dl****@nospam.nospamwrote in message
news:65**********************************@microsof t.com...
>>1) What are you using for session management? If you're not using inproc
sessions, Session_End won't fire...
>1. Using SQL.

Don't need to look any further than that, then...

Session_End() only fires for inproc sessions...

This hasn't changed since the last time you asked... :-)
http://www.thescripts.com/forum/thread574994.html
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Oct 2 '07 #7
"David Lozzi" <dl****@nospam.nospamwrote in message
news:4C**********************************@microsof t.com...
D'OH -- I thought I asked this once before.... Well, then, this is
embarassing...
Happens to the best of us... :-)
What are my options then? I need to capture an abandoned session's
objects.
This may help:
http://www.velocityreviews.com/forum...sion-mode.html
Also, how does a session never end when it's on SQL?
It does end.
Or does it and it doesn't tell IIS/Web site about it?
Correct.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Oct 2 '07 #8

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

Similar topics

4
by: Geoff Soper | last post by:
I'm working on an authentication system in which it's possible that a user might be requested to log-in as a result of submitting a form if the inactivity timeout is exceeded. In order that they...
3
by: Hemanth | last post by:
Hello there, I've a utility that runs on a linux machine. Basically, it opens a window, draws a figure and captures the image (screen) and stores it as a jpeg file. The utility requires a...
5
by: ashutosh.bhardwaj1980 | last post by:
Hi, I amdeveloping a web site in ASP and it is a secure site. I would like someone to help me on this: -->i dont want 2 users to accesss my site with the same username parallely. --> Also...
2
by: Hoegje | last post by:
I am writing a C++ program, which should create a sub- process to start a telnet session to another server. Then it should login to that server (on the telnet login) and execute one or more...
8
by: Zvonko | last post by:
Hi! Is it possible to capture an event when user leaves the page and execute some code? Not when he closes the window. Any ideas?
33
by: Joerg Schuster | last post by:
Hello, Python regular expressions must not have more than 100 capturing groups. The source code responsible for this reads as follows: # XXX: <fl> get rid of this limitation! if...
17
by: Lauren Wilson | last post by:
Does anyone know if it is possible to capture FTP responses to various FTP commands when managing an FTP session from a VBA procedure? For example, if we try to login to an FTP server and the...
1
by: sachinsjoshi | last post by:
Dear all, I have struck in one of the different type of requirement in SQL Server 2005. I need an equivalent functionality of capturing date and time based on client's timezime, as it is...
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...
0
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,...
0
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...
0
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
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
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...

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.