session_start/session_end

  • Thread starter Thread starter Bruno
  • Start date Start date
B

Bruno

We are attempting to automatically log users off from the Session_End event
in global.asax and set some values on session_start. It is not a critical
task, more of a housekeeping task so that we know if users have closed down
their browsers without logging off first. However, although the code seems
to run OK on our development servers (WinXP ASP.NET v. 1.1, SQL Server 2000,
IIS6), they don't seem to be firing on the live server despite sessions
working fine.

We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3 server running IIS
6.

Here is the c# code we used:-

/// <summary>

/// We can log the user out here so that the database will
reflect the correct number

/// users logged in.

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

protected void Session_End(object sender, EventArgs e)

{

// If user id is not null, log them out automatically...

object oId = Session["CurrentUserId"];



try

{

if (oId != null)

{

SqlInt32 intUserId =
SqlInt32.Parse(oId.ToString());



SessionServer.LogOut(intUserId,
Session.SessionID);



LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO,
intUserId, "Session logged out automatically.");

}

}



catch (Exception ex)
{LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
automatically.");}

}

Any ideas?
 
Hello bruno,

Session_End is not called even if browser is closed by user because HTTP
is stateless and server dont know whether you close browser.
It's is called when u call it explicit or session is expired by timeline

PS: Session_End is available onle in InProc mode

b> We are attempting to automatically log users off from the Session_End
b> event in global.asax and set some values on session_start. It is not
b> a critical task, more of a housekeeping task so that we know if users
b> have closed down their browsers without logging off first. However,
b> although the code seems to run OK on our development servers (WinXP
b> ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be firing
b> on the live server despite sessions working fine.
b>
b> We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3 server
b> running IIS 6.
b>
b> Here is the c# code we used:-
b>
b> /// <summary>
b>
b> /// We can log the user out here so that the database
b> will reflect the correct number
b>
b> /// users logged in.
b>
b> /// </summary>
b>
b> /// <param name="sender"></param>
b>
b> /// <param name="e"></param>
b>
b> protected void Session_End(object sender, EventArgs e)
b>
b> {
b>
b> // If user id is not null, log them out
b> automatically...
b>
b> object oId = Session["CurrentUserId"];
b>
b> try
b>
b> {
b>
b> if (oId != null)
b>
b> {
b>
b> SqlInt32 intUserId =
b> SqlInt32.Parse(oId.ToString());
b>
b> SessionServer.LogOut(intUserId,
b> Session.SessionID);
b>
b>
b> LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, intUserId,
b> "Session logged out automatically.");
b>
b> }
b>
b> }
b>
b> catch (Exception ex)
b> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
b> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
b> automatically.");}
b>
b> }
b>
b> Any ideas?
b>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
We are using InProc and we are aware of how it is supposed to function.

To clarify. It _is_ working on our development servers but _not_ on the live
server.
 
Hello bruno,

Sorry, missed it
Have u tried this one http://support.microsoft.com/?kbid=827164 ?
b> We are using InProc and we are aware of how it is supposed to
b> function.
b>
b> To clarify. It _is_ working on our development servers but _not_ on
b> the live server.
b>
b> b>
Hello bruno,

Session_End is not called even if browser is closed by user because
HTTP
is stateless and server dont know whether you close browser.
It's is called when u call it explicit or session is expired by
timeline
PS: Session_End is available onle in InProc mode

b> We are attempting to automatically log users off from the
Session_End
b> event in global.asax and set some values on session_start. It is
not
b> a critical task, more of a housekeeping task so that we know if
users
b> have closed down their browsers without logging off first.
However,
b> although the code seems to run OK on our development servers
(WinXP
b> ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be
firing
b> on the live server despite sessions working fine.
b> b> We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3
server
b> running IIS 6.
b> b> Here is the c# code we used:-
b> b> /// <summary>
b> b> /// We can log the user out here so that the database
b> will reflect the correct number
b> b> /// users logged in.
b> b> /// </summary>
b> b> /// <param name="sender"></param>
b> b> /// <param name="e"></param>
b> b> protected void Session_End(object sender, EventArgs e)
b> b> {
b> b> // If user id is not null, log them out
b> automatically...
b> b> object oId = Session["CurrentUserId"];
b> b> try
b> b> {
b> b> if (oId != null)
b> b> {
b> b> SqlInt32 intUserId =
b> SqlInt32.Parse(oId.ToString());
b> b> SessionServer.LogOut(intUserId,
b> Session.SessionID);
b> b> b> LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO,
intUserId,
b> "Session logged out automatically.");
b> b> }
b> b> }
b> b> catch (Exception ex)
b> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
b> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
b> automatically.");}
b> b> }
b> b> Any ideas?
b> ---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Hello bruno,

And check if correct version of ASP.net 1.1 is set in the Virtual Folder
properties of your site in IIS

b> We are using InProc and we are aware of how it is supposed to
b> function.
b>
b> To clarify. It _is_ working on our development servers but _not_ on
b> the live server.
b>
b> b>
Hello bruno,

Session_End is not called even if browser is closed by user because
HTTP
is stateless and server dont know whether you close browser.
It's is called when u call it explicit or session is expired by
timeline
PS: Session_End is available onle in InProc mode

b> We are attempting to automatically log users off from the
Session_End
b> event in global.asax and set some values on session_start. It is
not
b> a critical task, more of a housekeeping task so that we know if
users
b> have closed down their browsers without logging off first.
However,
b> although the code seems to run OK on our development servers
(WinXP
b> ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be
firing
b> on the live server despite sessions working fine.
b> b> We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3
server
b> running IIS 6.
b> b> Here is the c# code we used:-
b> b> /// <summary>
b> b> /// We can log the user out here so that the database
b> will reflect the correct number
b> b> /// users logged in.
b> b> /// </summary>
b> b> /// <param name="sender"></param>
b> b> /// <param name="e"></param>
b> b> protected void Session_End(object sender, EventArgs e)
b> b> {
b> b> // If user id is not null, log them out
b> automatically...
b> b> object oId = Session["CurrentUserId"];
b> b> try
b> b> {
b> b> if (oId != null)
b> b> {
b> b> SqlInt32 intUserId =
b> SqlInt32.Parse(oId.ToString());
b> b> SessionServer.LogOut(intUserId,
b> Session.SessionID);
b> b> b> LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO,
intUserId,
b> "Session logged out automatically.");
b> b> }
b> b> }
b> b> catch (Exception ex)
b> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
b> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
b> automatically.");}
b> b> }
b> b> Any ideas?
b> ---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
It's definately using the right version.

Michael Nemtsev said:
Hello bruno,

And check if correct version of ASP.net 1.1 is set in the Virtual Folder
properties of your site in IIS

b> We are using InProc and we are aware of how it is supposed to
b> function.
b> b> To clarify. It _is_ working on our development servers but _not_ on
b> the live server.
b> b>
Hello bruno,

Session_End is not called even if browser is closed by user because
HTTP
is stateless and server dont know whether you close browser.
It's is called when u call it explicit or session is expired by
timeline
PS: Session_End is available onle in InProc mode

b> We are attempting to automatically log users off from the
Session_End
b> event in global.asax and set some values on session_start. It is
not
b> a critical task, more of a housekeeping task so that we know if
users
b> have closed down their browsers without logging off first.
However,
b> although the code seems to run OK on our development servers
(WinXP
b> ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be
firing
b> on the live server despite sessions working fine.
b> b> We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3
server
b> running IIS 6.
b> b> Here is the c# code we used:-
b> b> /// <summary>
b> b> /// We can log the user out here so that the database
b> will reflect the correct number
b> b> /// users logged in.
b> b> /// </summary>
b> b> /// <param name="sender"></param>
b> b> /// <param name="e"></param>
b> b> protected void Session_End(object sender, EventArgs e)
b> b> {
b> b> // If user id is not null, log them out
b> automatically...
b> b> object oId = Session["CurrentUserId"];
b> b> try
b> b> {
b> b> if (oId != null)
b> b> {
b> b> SqlInt32 intUserId =
b> SqlInt32.Parse(oId.ToString());
b> b> SessionServer.LogOut(intUserId,
b> Session.SessionID);
b> b> b> LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO,
intUserId,
b> "Session logged out automatically.");
b> b> }
b> b> }
b> b> catch (Exception ex)
b> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
b> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
b> automatically.");}
b> b> }
b> b> Any ideas?
b> ---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
 
Session is firing on your dev server but not in production, is that right?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

Bruno said:
It's definately using the right version.

Michael Nemtsev said:
Hello bruno,

And check if correct version of ASP.net 1.1 is set in the Virtual Folder
properties of your site in IIS

b> We are using InProc and we are aware of how it is supposed to
b> function.
b> b> To clarify. It _is_ working on our development servers but _not_ on
b> the live server.
b> b>
Hello bruno,

Session_End is not called even if browser is closed by user because
HTTP
is stateless and server dont know whether you close browser.
It's is called when u call it explicit or session is expired by
timeline
PS: Session_End is available onle in InProc mode

b> We are attempting to automatically log users off from the
Session_End
b> event in global.asax and set some values on session_start. It is
not
b> a critical task, more of a housekeeping task so that we know if
users
b> have closed down their browsers without logging off first.
However,
b> although the code seems to run OK on our development servers
(WinXP
b> ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be
firing
b> on the live server despite sessions working fine.
b> b> We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3
server
b> running IIS 6.
b> b> Here is the c# code we used:-
b> b> /// <summary>
b> b> /// We can log the user out here so that the database
b> will reflect the correct number
b> b> /// users logged in.
b> b> /// </summary>
b> b> /// <param name="sender"></param>
b> b> /// <param name="e"></param>
b> b> protected void Session_End(object sender, EventArgs e)
b> b> {
b> b> // If user id is not null, log them out
b> automatically...
b> b> object oId = Session["CurrentUserId"];
b> b> try
b> b> {
b> b> if (oId != null)
b> b> {
b> b> SqlInt32 intUserId =
b> SqlInt32.Parse(oId.ToString());
b> b> SessionServer.LogOut(intUserId,
b> Session.SessionID);
b> b> b> LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO,
intUserId,
b> "Session logged out automatically.");
b> b> }
b> b> }
b> b> catch (Exception ex)
b> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
b> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
b> automatically.");}
b> b> }
b> b> Any ideas?
b> ---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
 
Yes that is right.

Alvin Bruney said:
Session is firing on your dev server but not in production, is that right?

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
-------------------------------------------------------

Bruno said:
It's definately using the right version.

Michael Nemtsev said:
Hello bruno,

And check if correct version of ASP.net 1.1 is set in the Virtual Folder
properties of your site in IIS

b> We are using InProc and we are aware of how it is supposed to
b> function.
b> b> To clarify. It _is_ working on our development servers but _not_
on
b> the live server.
b> b>
Hello bruno,

Session_End is not called even if browser is closed by user because
HTTP
is stateless and server dont know whether you close browser.
It's is called when u call it explicit or session is expired by
timeline
PS: Session_End is available onle in InProc mode

b> We are attempting to automatically log users off from the
Session_End
b> event in global.asax and set some values on session_start. It is
not
b> a critical task, more of a housekeeping task so that we know if
users
b> have closed down their browsers without logging off first.
However,
b> although the code seems to run OK on our development servers
(WinXP
b> ASP.NET v. 1.1, SQL Server 2000, IIS6), they don't seem to be
firing
b> on the live server despite sessions working fine.
b> b> We are using ASP.NET v. 1.1 and SQL Server 2000 on a W2K3
server
b> running IIS 6.
b> b> Here is the c# code we used:-
b> b> /// <summary>
b> b> /// We can log the user out here so that the database
b> will reflect the correct number
b> b> /// users logged in.
b> b> /// </summary>
b> b> /// <param name="sender"></param>
b> b> /// <param name="e"></param>
b> b> protected void Session_End(object sender, EventArgs e)
b> b> {
b> b> // If user id is not null, log them out
b> automatically...
b> b> object oId = Session["CurrentUserId"];
b> b> try
b> b> {
b> b> if (oId != null)
b> b> {
b> b> SqlInt32 intUserId =
b> SqlInt32.Parse(oId.ToString());
b> b> SessionServer.LogOut(intUserId,
b> Session.SessionID);
b> b> b> LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO,
intUserId,
b> "Session logged out automatically.");
b> b> }
b> b> }
b> b> catch (Exception ex)
b> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel.INFO, (null ==
b> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
b> automatically.");}
b> b> }
b> b> Any ideas?
b> ---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents
do not cease to be insipid." (c) Friedrich Nietzsche

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do
not cease to be insipid." (c) Friedrich Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top