B
Bruno
We are attempting to automatically log users off from the Session_End event
in global.asax. 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, it is not working on the live server.
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.");}
}
in global.asax. 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, it is not working on the live server.
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.");}
}