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

automatically.");}
}
Any ideas?