473,412 Members | 3,763 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,412 software developers and data experts.

Session_End

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.I NFO,
intUserId, "Session logged out automatically.");

}

}

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

}
Apr 1 '06 #1
14 2311
Are you using InProc session state mode in production?

Session_End event is raised only in InProc mode, not in any out-of-rpco
modse (StateServer, SqlServer). If you have it in InProc, I'd then suspect
there is something restarting the AppDomain or something, so that
Session_End wouldn't get raised but that would also cause users to lose
sessions every time and I'd think you'd have noticed that.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
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.I NFO, intUserId, "Session
logged out automatically.");

}

}

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

}

Apr 1 '06 #2
We are using InProc what could cause AppDomain to be restarted?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Are you using InProc session state mode in production?

Session_End event is raised only in InProc mode, not in any out-of-rpco
modse (StateServer, SqlServer). If you have it in InProc, I'd then suspect
there is something restarting the AppDomain or something, so that
Session_End wouldn't get raised but that would also cause users to lose
sessions every time and I'd think you'd have noticed that.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
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.I NFO, intUserId,
"Session logged out automatically.");

}

}

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

}


Apr 1 '06 #3
We've got it compiled for release mode on the live machine and debug mode on
the development machine. Do you think that has anything to do with it?

"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We are using InProc what could cause AppDomain to be restarted?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Are you using InProc session state mode in production?

Session_End event is raised only in InProc mode, not in any out-of-rpco
modse (StateServer, SqlServer). If you have it in InProc, I'd then
suspect there is something restarting the AppDomain or something, so that
Session_End wouldn't get raised but that would also cause users to lose
sessions every time and I'd think you'd have noticed that.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
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.I NFO, intUserId,
"Session logged out automatically.");

}

}

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

}



Apr 1 '06 #4
For example

- virus scanners reading dll's in bin folder or global.asax/web.config
- maximum number of dynamic page compilations teached
- directory rename under web app folder
-many file changes in the contect directories (like with dynamic file
generating)
-...

But you'd notice that since your users would lose their sessions as well.
Have you noted such (if you have, you can log for the reason with:
http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you
haven't, then I wouldn't yet investigate that possibility.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We are using InProc what could cause AppDomain to be restarted?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Are you using InProc session state mode in production?

Session_End event is raised only in InProc mode, not in any out-of-rpco
modse (StateServer, SqlServer). If you have it in InProc, I'd then
suspect there is something restarting the AppDomain or something, so that
Session_End wouldn't get raised but that would also cause users to lose
sessions every time and I'd think you'd have noticed that.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
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.I NFO, intUserId,
"Session logged out automatically.");

}

}

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

}



Apr 1 '06 #5
We aren't having problems with sessions getting lost. Are there any hotfixes
or service packs which may have fixed errors with this?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
For example

- virus scanners reading dll's in bin folder or global.asax/web.config
- maximum number of dynamic page compilations teached
- directory rename under web app folder
-many file changes in the contect directories (like with dynamic file
generating)
-...

But you'd notice that since your users would lose their sessions as well.
Have you noted such (if you have, you can log for the reason with:
http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you
haven't, then I wouldn't yet investigate that possibility.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We are using InProc what could cause AppDomain to be restarted?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Are you using InProc session state mode in production?

Session_End event is raised only in InProc mode, not in any out-of-rpco
modse (StateServer, SqlServer). If you have it in InProc, I'd then
suspect there is something restarting the AppDomain or something, so
that Session_End wouldn't get raised but that would also cause users to
lose sessions every time and I'd think you'd have noticed that.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
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.I NFO, intUserId,
"Session logged out automatically.");

}

}

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

}



Apr 1 '06 #6
No,

it's normal that when AppDomain restarts, InProc sessions are lost. In this
case it means that you are not experiencing any restarts. Instead of your
log-off-code, have you tried placing something simpler into Session_End such
as writing a line to a physical file or something? To restrict that it
wouldn't be a permission issue.

You might also want to check this Session FAQ:
http://forums.asp.net/7504/ShowPost.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
We aren't having problems with sessions getting lost. Are there any
hotfixes or service packs which may have fixed errors with this?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
For example

- virus scanners reading dll's in bin folder or global.asax/web.config
- maximum number of dynamic page compilations teached
- directory rename under web app folder
-many file changes in the contect directories (like with dynamic file
generating)
-...

But you'd notice that since your users would lose their sessions as well.
Have you noted such (if you have, you can log for the reason with:
http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you
haven't, then I wouldn't yet investigate that possibility.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We are using InProc what could cause AppDomain to be restarted?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
Are you using InProc session state mode in production?

Session_End event is raised only in InProc mode, not in any out-of-rpco
modse (StateServer, SqlServer). If you have it in InProc, I'd then
suspect there is something restarting the AppDomain or something, so
that Session_End wouldn't get raised but that would also cause users to
lose sessions every time and I'd think you'd have noticed that.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
> 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.I NFO, intUserId,
> "Session logged out automatically.");
>
> }
>
> }
>
>
>
> catch (Exception ex)
> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
> automatically.");}
>
> }
>
>



Apr 1 '06 #7
We've tried writing to a file aswell and there are no attempts to write to
the file according to Filemon.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
No,

it's normal that when AppDomain restarts, InProc sessions are lost. In
this case it means that you are not experiencing any restarts. Instead of
your log-off-code, have you tried placing something simpler into
Session_End such as writing a line to a physical file or something? To
restrict that it wouldn't be a permission issue.

You might also want to check this Session FAQ:
http://forums.asp.net/7504/ShowPost.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
We aren't having problems with sessions getting lost. Are there any
hotfixes or service packs which may have fixed errors with this?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
For example

- virus scanners reading dll's in bin folder or global.asax/web.config
- maximum number of dynamic page compilations teached
- directory rename under web app folder
-many file changes in the contect directories (like with dynamic file
generating)
-...

But you'd notice that since your users would lose their sessions as
well. Have you noted such (if you have, you can log for the reason with:
http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you
haven't, then I wouldn't yet investigate that possibility.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We are using InProc what could cause AppDomain to be restarted?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
> Are you using InProc session state mode in production?
>
> Session_End event is raised only in InProc mode, not in any
> out-of-rpco modse (StateServer, SqlServer). If you have it in InProc,
> I'd then suspect there is something restarting the AppDomain or
> something, so that Session_End wouldn't get raised but that would also
> cause users to lose sessions every time and I'd think you'd have
> noticed that.
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
> "Bruno" <de********@hotmail.com> wrote in message
> news:44***********************@news.zen.co.uk...
>> 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.I NFO, intUserId,
>> "Session logged out automatically.");
>>
>> }
>>
>> }
>>
>>
>>
>> catch (Exception ex)
>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
>> automatically.");}
>>
>> }
>>
>>
>
>



Apr 3 '06 #8
Anyone else got any ideas at all? Apparently session_start is not working
either.

"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We've tried writing to a file aswell and there are no attempts to write to
the file according to Filemon.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
No,

it's normal that when AppDomain restarts, InProc sessions are lost. In
this case it means that you are not experiencing any restarts. Instead of
your log-off-code, have you tried placing something simpler into
Session_End such as writing a line to a physical file or something? To
restrict that it wouldn't be a permission issue.

You might also want to check this Session FAQ:
http://forums.asp.net/7504/ShowPost.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
We aren't having problems with sessions getting lost. Are there any
hotfixes or service packs which may have fixed errors with this?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
For example

- virus scanners reading dll's in bin folder or global.asax/web.config
- maximum number of dynamic page compilations teached
- directory rename under web app folder
-many file changes in the contect directories (like with dynamic file
generating)
-...

But you'd notice that since your users would lose their sessions as
well. Have you noted such (if you have, you can log for the reason
with: http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ?
If you haven't, then I wouldn't yet investigate that possibility.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
> We are using InProc what could cause AppDomain to be restarted?
>
> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
> news:en**************@tk2msftngp13.phx.gbl...
>> Are you using InProc session state mode in production?
>>
>> Session_End event is raised only in InProc mode, not in any
>> out-of-rpco modse (StateServer, SqlServer). If you have it in InProc,
>> I'd then suspect there is something restarting the AppDomain or
>> something, so that Session_End wouldn't get raised but that would
>> also cause users to lose sessions every time and I'd think you'd have
>> noticed that.
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>>
>> "Bruno" <de********@hotmail.com> wrote in message
>> news:44***********************@news.zen.co.uk...
>>> 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.I NFO, intUserId,
>>> "Session logged out automatically.");
>>>
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> catch (Exception ex)
>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
>>> automatically.");}
>>>
>>> }
>>>
>>>
>>
>>
>
>



Apr 3 '06 #9
Bruno,

what happens if you do this :

Session("test") = "testvalue"

Can you retrieve that session value with

<%=Session("test")%>

?

If you can, Session_Start *must* have fired.

Also, check your <pages...> section in web.config and/or machine.config

Is session state enabled ?

<pages enableSessionState="true">


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message news:44**********************@news.zen.co.uk...
Anyone else got any ideas at all? Apparently session_start is not working either.

"Bruno" <de********@hotmail.com> wrote in message news:44*********************@news.zen.co.uk...
We've tried writing to a file aswell and there are no attempts to write to the file according to
Filemon.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
No,

it's normal that when AppDomain restarts, InProc sessions are lost. In this case it means that
you are not experiencing any restarts. Instead of your log-off-code, have you tried placing
something simpler into Session_End such as writing a line to a physical file or something? To
restrict that it wouldn't be a permission issue.

You might also want to check this Session FAQ: http://forums.asp.net/7504/ShowPost.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
We aren't having problems with sessions getting lost. Are there any hotfixes or service packs
which may have fixed errors with this?

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:e8**************@TK2MSFTNGP12.phx.gbl...
> For example
>
> - virus scanners reading dll's in bin folder or global.asax/web.config
> - maximum number of dynamic page compilations teached
> - directory rename under web app folder
> -many file changes in the contect directories (like with dynamic file generating)
> -...
>
> But you'd notice that since your users would lose their sessions as well. Have you noted such
> (if you have, you can log for the reason with:
> http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you haven't, then I
> wouldn't yet investigate that possibility.
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
> "Bruno" <de********@hotmail.com> wrote in message
> news:44*********************@news.zen.co.uk...
>> We are using InProc what could cause AppDomain to be restarted?
>>
>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>> news:en**************@tk2msftngp13.phx.gbl...
>>> Are you using InProc session state mode in production?
>>>
>>> Session_End event is raised only in InProc mode, not in any out-of-rpco modse (StateServer,
>>> SqlServer). If you have it in InProc, I'd then suspect there is something restarting the
>>> AppDomain or something, so that Session_End wouldn't get raised but that would also cause
>>> users to lose sessions every time and I'd think you'd have noticed that.
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>>
>>> "Bruno" <de********@hotmail.com> wrote in message
>>> news:44***********************@news.zen.co.uk...
>>>> 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.I NFO, intUserId, "Session logged out
>>>> automatically.");
>>>>
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> catch (Exception ex)
>>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>>>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out automatically.");}
>>>>
>>>> }
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #10
Sessions are definately working. It's just the session_end and session_start
under global.asax which aren't being fired. They work fine on the
development server but not on the live server.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Bruno,

what happens if you do this :

Session("test") = "testvalue"

Can you retrieve that session value with

<%=Session("test")%>

?

If you can, Session_Start *must* have fired.

Also, check your <pages...> section in web.config and/or machine.config

Is session state enabled ?

<pages enableSessionState="true">


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message
news:44**********************@news.zen.co.uk...
Anyone else got any ideas at all? Apparently session_start is not working
either.

"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
We've tried writing to a file aswell and there are no attempts to write
to the file according to Filemon.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
No,

it's normal that when AppDomain restarts, InProc sessions are lost. In
this case it means that you are not experiencing any restarts. Instead
of your log-off-code, have you tried placing something simpler into
Session_End such as writing a line to a physical file or something? To
restrict that it wouldn't be a permission issue.

You might also want to check this Session FAQ:
http://forums.asp.net/7504/ShowPost.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
"Bruno" <de********@hotmail.com> wrote in message
news:44***********************@news.zen.co.uk...
> We aren't having problems with sessions getting lost. Are there any
> hotfixes or service packs which may have fixed errors with this?
>
> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
> news:e8**************@TK2MSFTNGP12.phx.gbl...
>> For example
>>
>> - virus scanners reading dll's in bin folder or
>> global.asax/web.config
>> - maximum number of dynamic page compilations teached
>> - directory rename under web app folder
>> -many file changes in the contect directories (like with dynamic file
>> generating)
>> -...
>>
>> But you'd notice that since your users would lose their sessions as
>> well. Have you noted such (if you have, you can log for the reason
>> with: http://weblogs.asp.net/scottgu/archi...14/433194.aspx)
>> ? If you haven't, then I wouldn't yet investigate that possibility.
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>>
>> "Bruno" <de********@hotmail.com> wrote in message
>> news:44*********************@news.zen.co.uk...
>>> We are using InProc what could cause AppDomain to be restarted?
>>>
>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>> news:en**************@tk2msftngp13.phx.gbl...
>>>> Are you using InProc session state mode in production?
>>>>
>>>> Session_End event is raised only in InProc mode, not in any
>>>> out-of-rpco modse (StateServer, SqlServer). If you have it in
>>>> InProc, I'd then suspect there is something restarting the
>>>> AppDomain or something, so that Session_End wouldn't get raised but
>>>> that would also cause users to lose sessions every time and I'd
>>>> think you'd have noticed that.
>>>>
>>>> --
>>>> Teemu Keiski
>>>> ASP.NET MVP, AspInsider
>>>> Finland, EU
>>>> http://blogs.aspadvice.com/joteke
>>>>
>>>>
>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>> news:44***********************@news.zen.co.uk...
>>>>> 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.I NFO, intUserId,
>>>>> "Session logged out automatically.");
>>>>>
>>>>> }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> catch (Exception ex)
>>>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>>>>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
>>>>> automatically.");}
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #11
re:
Sessions are definately working. It's just the session_end and session_start under global.asax
which aren't being fired.
Sorry, Bruno.
If sessions are working, Session_Start *must* have fired.

Maybe you are trying to code against objects which are not reachable from Session_Start ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message news:44**********************@news.zen.co.uk... Sessions are definately working. It's just the session_end and session_start under global.asax
which aren't being fired. They work fine on the development server but not on the live server.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Bruno,

what happens if you do this :

Session("test") = "testvalue"

Can you retrieve that session value with

<%=Session("test")%>

?

If you can, Session_Start *must* have fired.

Also, check your <pages...> section in web.config and/or machine.config

Is session state enabled ?

<pages enableSessionState="true">


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message news:44**********************@news.zen.co.uk...
Anyone else got any ideas at all? Apparently session_start is not working either.

"Bruno" <de********@hotmail.com> wrote in message news:44*********************@news.zen.co.uk...
We've tried writing to a file aswell and there are no attempts to write to the file according
to Filemon.

"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:ue**************@TK2MSFTNGP15.phx.gbl...
> No,
>
> it's normal that when AppDomain restarts, InProc sessions are lost. In this case it means that
> you are not experiencing any restarts. Instead of your log-off-code, have you tried placing
> something simpler into Session_End such as writing a line to a physical file or something? To
> restrict that it wouldn't be a permission issue.
>
> You might also want to check this Session FAQ: http://forums.asp.net/7504/ShowPost.aspx
>
> --
> Teemu Keiski
> ASP.NET MVP, AspInsider
> Finland, EU
> http://blogs.aspadvice.com/joteke
>
>
> "Bruno" <de********@hotmail.com> wrote in message
> news:44***********************@news.zen.co.uk...
>> We aren't having problems with sessions getting lost. Are there any hotfixes or service packs
>> which may have fixed errors with this?
>>
>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>> For example
>>>
>>> - virus scanners reading dll's in bin folder or global.asax/web.config
>>> - maximum number of dynamic page compilations teached
>>> - directory rename under web app folder
>>> -many file changes in the contect directories (like with dynamic file generating)
>>> -...
>>>
>>> But you'd notice that since your users would lose their sessions as well. Have you noted
>>> such (if you have, you can log for the reason with:
>>> http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you haven't, then I
>>> wouldn't yet investigate that possibility.
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>>
>>> "Bruno" <de********@hotmail.com> wrote in message
>>> news:44*********************@news.zen.co.uk...
>>>> We are using InProc what could cause AppDomain to be restarted?
>>>>
>>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>>> news:en**************@tk2msftngp13.phx.gbl...
>>>>> Are you using InProc session state mode in production?
>>>>>
>>>>> Session_End event is raised only in InProc mode, not in any out-of-rpco modse
>>>>> (StateServer, SqlServer). If you have it in InProc, I'd then suspect there is something
>>>>> restarting the AppDomain or something, so that Session_End wouldn't get raised but that
>>>>> would also cause users to lose sessions every time and I'd think you'd have noticed that.
>>>>>
>>>>> --
>>>>> Teemu Keiski
>>>>> ASP.NET MVP, AspInsider
>>>>> Finland, EU
>>>>> http://blogs.aspadvice.com/joteke
>>>>>
>>>>>
>>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>>> news:44***********************@news.zen.co.uk...
>>>>>> 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.I NFO, intUserId, "Session logged out
>>>>>> automatically.");
>>>>>>
>>>>>> }
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> catch (Exception ex)
>>>>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>>>>>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out automatically.");}
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #12
> Sorry, Bruno.
If sessions are working, Session_Start *must* have fired. A valid point, however, it is not executing the code within.
Maybe you are trying to code against objects which are not reachable from
Session_Start ?
As I mentioned we have it working on two development servers so we know it
works. Just not on the live server for some reason.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl... re:
Sessions are definately working. It's just the session_end and
session_start under global.asax which aren't being fired.


Sorry, Bruno.
If sessions are working, Session_Start *must* have fired.

Maybe you are trying to code against objects which are not reachable from
Session_Start ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message
news:44**********************@news.zen.co.uk...
Sessions are definately working. It's just the session_end and
session_start under global.asax which aren't being fired. They work fine
on the development server but not on the live server.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Bruno,

what happens if you do this :

Session("test") = "testvalue"

Can you retrieve that session value with

<%=Session("test")%>

?

If you can, Session_Start *must* have fired.

Also, check your <pages...> section in web.config and/or machine.config

Is session state enabled ?

<pages enableSessionState="true">


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message
news:44**********************@news.zen.co.uk...
Anyone else got any ideas at all? Apparently session_start is not
working either.

"Bruno" <de********@hotmail.com> wrote in message
news:44*********************@news.zen.co.uk...
> We've tried writing to a file aswell and there are no attempts to
> write to the file according to Filemon.
>
> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
> news:ue**************@TK2MSFTNGP15.phx.gbl...
>> No,
>>
>> it's normal that when AppDomain restarts, InProc sessions are lost.
>> In this case it means that you are not experiencing any restarts.
>> Instead of your log-off-code, have you tried placing something
>> simpler into Session_End such as writing a line to a physical file or
>> something? To restrict that it wouldn't be a permission issue.
>>
>> You might also want to check this Session FAQ:
>> http://forums.asp.net/7504/ShowPost.aspx
>>
>> --
>> Teemu Keiski
>> ASP.NET MVP, AspInsider
>> Finland, EU
>> http://blogs.aspadvice.com/joteke
>>
>>
>> "Bruno" <de********@hotmail.com> wrote in message
>> news:44***********************@news.zen.co.uk...
>>> We aren't having problems with sessions getting lost. Are there any
>>> hotfixes or service packs which may have fixed errors with this?
>>>
>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>>> For example
>>>>
>>>> - virus scanners reading dll's in bin folder or
>>>> global.asax/web.config
>>>> - maximum number of dynamic page compilations teached
>>>> - directory rename under web app folder
>>>> -many file changes in the contect directories (like with dynamic
>>>> file generating)
>>>> -...
>>>>
>>>> But you'd notice that since your users would lose their sessions as
>>>> well. Have you noted such (if you have, you can log for the reason
>>>> with:
>>>> http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If
>>>> you haven't, then I wouldn't yet investigate that possibility.
>>>>
>>>> --
>>>> Teemu Keiski
>>>> ASP.NET MVP, AspInsider
>>>> Finland, EU
>>>> http://blogs.aspadvice.com/joteke
>>>>
>>>>
>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>> news:44*********************@news.zen.co.uk...
>>>>> We are using InProc what could cause AppDomain to be restarted?
>>>>>
>>>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>>>> news:en**************@tk2msftngp13.phx.gbl...
>>>>>> Are you using InProc session state mode in production?
>>>>>>
>>>>>> Session_End event is raised only in InProc mode, not in any
>>>>>> out-of-rpco modse (StateServer, SqlServer). If you have it in
>>>>>> InProc, I'd then suspect there is something restarting the
>>>>>> AppDomain or something, so that Session_End wouldn't get raised
>>>>>> but that would also cause users to lose sessions every time and
>>>>>> I'd think you'd have noticed that.
>>>>>>
>>>>>> --
>>>>>> Teemu Keiski
>>>>>> ASP.NET MVP, AspInsider
>>>>>> Finland, EU
>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>
>>>>>>
>>>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>>>> news:44***********************@news.zen.co.uk...
>>>>>>> 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.I NFO,
>>>>>>> intUserId, "Session logged out automatically.");
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> catch (Exception ex)
>>>>>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>>>>>>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out
>>>>>>> automatically.");}
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #13
I can only suggest that you post some of the offending code, then.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message news:44**********************@news.zen.co.uk...
Sorry, Bruno.
If sessions are working, Session_Start *must* have fired.

A valid point, however, it is not executing the code within.
Maybe you are trying to code against objects which are not reachable from Session_Start ?


As I mentioned we have it working on two development servers so we know it works. Just not on the
live server for some reason.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl...
re:
Sessions are definately working. It's just the session_end and session_start under global.asax
which aren't being fired.


Sorry, Bruno.
If sessions are working, Session_Start *must* have fired.

Maybe you are trying to code against objects which are not reachable from Session_Start ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message news:44**********************@news.zen.co.uk...
Sessions are definately working. It's just the session_end and session_start under global.asax
which aren't being fired. They work fine on the development server but not on the live server.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Bruno,

what happens if you do this :

Session("test") = "testvalue"

Can you retrieve that session value with

<%=Session("test")%>

?

If you can, Session_Start *must* have fired.

Also, check your <pages...> section in web.config and/or machine.config

Is session state enabled ?

<pages enableSessionState="true">


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message
news:44**********************@news.zen.co.uk...
> Anyone else got any ideas at all? Apparently session_start is not working either.
>
> "Bruno" <de********@hotmail.com> wrote in message
> news:44*********************@news.zen.co.uk...
>> We've tried writing to a file aswell and there are no attempts to write to the file according
>> to Filemon.
>>
>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>> news:ue**************@TK2MSFTNGP15.phx.gbl...
>>> No,
>>>
>>> it's normal that when AppDomain restarts, InProc sessions are lost. In this case it means
>>> that you are not experiencing any restarts. Instead of your log-off-code, have you tried
>>> placing something simpler into Session_End such as writing a line to a physical file or
>>> something? To restrict that it wouldn't be a permission issue.
>>>
>>> You might also want to check this Session FAQ: http://forums.asp.net/7504/ShowPost.aspx
>>>
>>> --
>>> Teemu Keiski
>>> ASP.NET MVP, AspInsider
>>> Finland, EU
>>> http://blogs.aspadvice.com/joteke
>>>
>>>
>>> "Bruno" <de********@hotmail.com> wrote in message
>>> news:44***********************@news.zen.co.uk...
>>>> We aren't having problems with sessions getting lost. Are there any hotfixes or service
>>>> packs which may have fixed errors with this?
>>>>
>>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>>>> For example
>>>>>
>>>>> - virus scanners reading dll's in bin folder or global.asax/web.config
>>>>> - maximum number of dynamic page compilations teached
>>>>> - directory rename under web app folder
>>>>> -many file changes in the contect directories (like with dynamic file generating)
>>>>> -...
>>>>>
>>>>> But you'd notice that since your users would lose their sessions as well. Have you noted
>>>>> such (if you have, you can log for the reason with:
>>>>> http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ? If you haven't, then I
>>>>> wouldn't yet investigate that possibility.
>>>>>
>>>>> --
>>>>> Teemu Keiski
>>>>> ASP.NET MVP, AspInsider
>>>>> Finland, EU
>>>>> http://blogs.aspadvice.com/joteke
>>>>>
>>>>>
>>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>>> news:44*********************@news.zen.co.uk...
>>>>>> We are using InProc what could cause AppDomain to be restarted?
>>>>>>
>>>>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>>>>> news:en**************@tk2msftngp13.phx.gbl...
>>>>>>> Are you using InProc session state mode in production?
>>>>>>>
>>>>>>> Session_End event is raised only in InProc mode, not in any out-of-rpco modse
>>>>>>> (StateServer, SqlServer). If you have it in InProc, I'd then suspect there is something
>>>>>>> restarting the AppDomain or something, so that Session_End wouldn't get raised but that
>>>>>>> would also cause users to lose sessions every time and I'd think you'd have noticed
>>>>>>> that.
>>>>>>>
>>>>>>> --
>>>>>>> Teemu Keiski
>>>>>>> ASP.NET MVP, AspInsider
>>>>>>> Finland, EU
>>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>>
>>>>>>>
>>>>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>>>>> news:44***********************@news.zen.co.uk...
>>>>>>>> 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.I NFO, intUserId, "Session logged out
>>>>>>>> automatically.");
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> catch (Exception ex)
>>>>>>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null ==
>>>>>>>> oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session out automatically.");}
>>>>>>>>
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 3 '06 #14
Please see original post.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uK****************@TK2MSFTNGP15.phx.gbl...
I can only suggest that you post some of the offending code, then.


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message
news:44**********************@news.zen.co.uk...
Sorry, Bruno.
If sessions are working, Session_Start *must* have fired.

A valid point, however, it is not executing the code within.
Maybe you are trying to code against objects which are not reachable
from Session_Start ?


As I mentioned we have it working on two development servers so we know
it works. Just not on the live server for some reason.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:ul**************@TK2MSFTNGP15.phx.gbl...
re:
Sessions are definately working. It's just the session_end and
session_start under global.asax which aren't being fired.

Sorry, Bruno.
If sessions are working, Session_Start *must* have fired.

Maybe you are trying to code against objects which are not reachable
from Session_Start ?

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaņol : http://asp.net.do/foros/
===================================
"Bruno" <de********@hotmail.com> wrote in message
news:44**********************@news.zen.co.uk...
Sessions are definately working. It's just the session_end and
session_start under global.asax which aren't being fired. They work
fine on the development server but not on the live server.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
> Bruno,
>
> what happens if you do this :
>
> Session("test") = "testvalue"
>
> Can you retrieve that session value with
>
> <%=Session("test")%>
>
> ?
>
> If you can, Session_Start *must* have fired.
>
> Also, check your <pages...> section in web.config and/or
> machine.config
>
> Is session state enabled ?
>
> <pages enableSessionState="true">
>
>
>
>
>
>
> Juan T. Llibre, asp.net MVP
> aspnetfaq.com : http://www.aspnetfaq.com/
> asp.net faq : http://asp.net.do/faq/
> foros de asp.net, en espaņol : http://asp.net.do/foros/
> ===================================
> "Bruno" <de********@hotmail.com> wrote in message
> news:44**********************@news.zen.co.uk...
>> Anyone else got any ideas at all? Apparently session_start is not
>> working either.
>>
>> "Bruno" <de********@hotmail.com> wrote in message
>> news:44*********************@news.zen.co.uk...
>>> We've tried writing to a file aswell and there are no attempts to
>>> write to the file according to Filemon.
>>>
>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>> news:ue**************@TK2MSFTNGP15.phx.gbl...
>>>> No,
>>>>
>>>> it's normal that when AppDomain restarts, InProc sessions are lost.
>>>> In this case it means that you are not experiencing any restarts.
>>>> Instead of your log-off-code, have you tried placing something
>>>> simpler into Session_End such as writing a line to a physical file
>>>> or something? To restrict that it wouldn't be a permission issue.
>>>>
>>>> You might also want to check this Session FAQ:
>>>> http://forums.asp.net/7504/ShowPost.aspx
>>>>
>>>> --
>>>> Teemu Keiski
>>>> ASP.NET MVP, AspInsider
>>>> Finland, EU
>>>> http://blogs.aspadvice.com/joteke
>>>>
>>>>
>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>> news:44***********************@news.zen.co.uk...
>>>>> We aren't having problems with sessions getting lost. Are there
>>>>> any hotfixes or service packs which may have fixed errors with
>>>>> this?
>>>>>
>>>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>>>> news:e8**************@TK2MSFTNGP12.phx.gbl...
>>>>>> For example
>>>>>>
>>>>>> - virus scanners reading dll's in bin folder or
>>>>>> global.asax/web.config
>>>>>> - maximum number of dynamic page compilations teached
>>>>>> - directory rename under web app folder
>>>>>> -many file changes in the contect directories (like with dynamic
>>>>>> file generating)
>>>>>> -...
>>>>>>
>>>>>> But you'd notice that since your users would lose their sessions
>>>>>> as well. Have you noted such (if you have, you can log for the
>>>>>> reason with:
>>>>>> http://weblogs.asp.net/scottgu/archi...14/433194.aspx) ?
>>>>>> If you haven't, then I wouldn't yet investigate that possibility.
>>>>>>
>>>>>> --
>>>>>> Teemu Keiski
>>>>>> ASP.NET MVP, AspInsider
>>>>>> Finland, EU
>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>
>>>>>>
>>>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>>>> news:44*********************@news.zen.co.uk...
>>>>>>> We are using InProc what could cause AppDomain to be restarted?
>>>>>>>
>>>>>>> "Teemu Keiski" <jo****@aspalliance.com> wrote in message
>>>>>>> news:en**************@tk2msftngp13.phx.gbl...
>>>>>>>> Are you using InProc session state mode in production?
>>>>>>>>
>>>>>>>> Session_End event is raised only in InProc mode, not in any
>>>>>>>> out-of-rpco modse (StateServer, SqlServer). If you have it in
>>>>>>>> InProc, I'd then suspect there is something restarting the
>>>>>>>> AppDomain or something, so that Session_End wouldn't get raised
>>>>>>>> but that would also cause users to lose sessions every time and
>>>>>>>> I'd think you'd have noticed that.
>>>>>>>>
>>>>>>>> --
>>>>>>>> Teemu Keiski
>>>>>>>> ASP.NET MVP, AspInsider
>>>>>>>> Finland, EU
>>>>>>>> http://blogs.aspadvice.com/joteke
>>>>>>>>
>>>>>>>>
>>>>>>>> "Bruno" <de********@hotmail.com> wrote in message
>>>>>>>> news:44***********************@news.zen.co.uk...
>>>>>>>>> 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.I NFO,
>>>>>>>>> intUserId, "Session logged out automatically.");
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> catch (Exception ex)
>>>>>>>>> {LogWriter.InsertAuditTrail(TypeServer.AuditLevel. INFO, (null
>>>>>>>>> == oId)?SqlInt32.Null:(SqlInt32)oId, "Error logging session
>>>>>>>>> out automatically.");}
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Apr 4 '06 #15

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

Similar topics

2
by: Chris Sibel | last post by:
Hey guys I have a user tracking setup to track users. What it does is once a user hits my site it sends me an email telling me some info and once a user clicks the logout button it sends a second...
9
by: Kenn Ghannon | last post by:
I've got an ASP.NET page with a counter subtraction routine in the Session_End method in the Global.asax.cs: protected void Session_End(Object sender, EventArgs e) { ulong curUsers; ...
2
by: Bela | last post by:
Hello I was wondering if someone could help me out with a Session_End problem in my Global.asax. I've tried everything, and still no success Here is the scenario: sessionstate is set to InProc....
3
by: Guadala Harry | last post by:
Just wondering if Session_End *always fires* for every Session. I know that IIS times out sessions after a default 20 min (unless changed) and there's no way to know when a user actually closed a...
4
by: Kim Bach Petersen | last post by:
I would like to record user behavior data stored in session variables. Since the data is modified throughout each session it seemed obvious to store the data when the session terminates - using...
7
by: Henry | last post by:
I have a question on session_end. I'm trying to log into my database when the session times out, it will store user info into a table. When I got step into a line where I was trying to open...
11
by: OldProgrammer | last post by:
All the documentation and discussion I have read indicate that the Session_End is not supposed to fire unless you are in "inProc" Session state mode, and then only on Session Timeout or at Session...
8
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
1
by: =?Utf-8?B?YnJlbnQ5NjA=?= | last post by:
Environment: ASP.NET 2.0, SQL Server 2005, C#, Visual Studio 2005 In my Session_End event, I am executing a stored procedure to update a database table that is used to log user sessions. When...
12
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I am trying to maintain a list of people who are currently "online" in SQL. I do this by adding a simple entry to a simple PeopleOnline table whenever someone logs in to my site. If they...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.