PC Review


Reply
Thread Tools Rate Thread

Capturing Session End...

 
 
David Lozzi
Guest
Posts: n/a
 
      1st Oct 2007
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

 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      1st Oct 2007
"David Lozzi" <(E-Mail Removed)> wrote in message
newsC803695-2F09-4CAD-A916-(E-Mail Removed)...

> 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

 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      1st Oct 2007
On Oct 1, 7:58 pm, "David Lozzi" <dlo...@nospam.nospam> wrote:
> 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

 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      1st Oct 2007
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" <(E-Mail Removed)> wrote in message
newsC803695-2F09-4CAD-A916-(E-Mail Removed)...
> 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



 
Reply With Quote
 
David Lozzi
Guest
Posts: n/a
 
      2nd Oct 2007
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("ErrorEmailFrom"))

Dim toEmails() As String =
ConfigurationManager.AppSettings("ErrorEmailTo").Split(";")
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:</b> SessionLog<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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "David Lozzi" <(E-Mail Removed)> wrote in message
> newsC803695-2F09-4CAD-A916-(E-Mail Removed)...
>
>> 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


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      2nd Oct 2007
"David Lozzi" <(E-Mail Removed)> wrote in message
news:65DBF543-789D-4385-92DE-(E-Mail Removed)...

>> 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

 
Reply With Quote
 
David Lozzi
Guest
Posts: n/a
 
      2nd Oct 2007
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]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "David Lozzi" <(E-Mail Removed)> wrote in message
> news:65DBF543-789D-4385-92DE-(E-Mail Removed)...
>
>>> 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


 
Reply With Quote
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      2nd Oct 2007
"David Lozzi" <(E-Mail Removed)> wrote in message
news:4CCE0EDE-E882-4CAC-90C2-(E-Mail Removed)...

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session Timeout problems-web.confg session state and IIS session s =?Utf-8?B?Um9iSEs=?= Microsoft ASP .NET 4 11th Apr 2007 05:52 PM
Cross Session Error? Session state and kernel-mode output caching don't mix jason Microsoft ASP .NET 0 30th Aug 2006 06:09 AM
Session Data lost randomly and Session State expired early =?Utf-8?B?Q0o=?= Microsoft Dot NET 0 17th Feb 2005 02:01 AM
Writing Session Specific Code For Windows 2003 Terminal Server Session OHM Microsoft VB .NET 8 27th May 2004 10:38 AM
Session State - What does it take to establish one single ASP.NET session per "browser session" Jeff Smythe Microsoft ASP .NET 3 2nd Jan 2004 04:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:10 PM.