Windows Server 2003 SP2 Broke My Site
-
I have a classic ASP web site that has been running flawlessly for at least 6 years now. I updated Windows Server 2003 to SP2 a few days ago, and now a "session counter" that I had implemented in Global.asa no longer works. Here is the code. From Global.asa:
function Application_OnStart()
{
Application("Visitors") = 0;
}function Session_OnStart()
{
Application.Lock();
{
Application("Visitors") = Application("Visitors") + 1;
}
Application.Unlock();// remainder of this function omitted, as it is irrelevant
}
function Session_OnEnd()
{
Application.Lock();
{
iVisitors = Application("Visitors");
if( iVisitors > 0 )
{
Application("Visitors") = iVisitors - 1;
}
else
{
Application("Visitors") = 0;
}
}
Application.Unlock();
}It appears to me that Session_OnEnd is never being called now, because Application("Visitors") keeps incrementing with each session BUT never deincrements since installing SP2! The code is so simple, that I can't see any reason why it is not doing so. Can anyone see a flaw in my code? Or am I just hosed? :(
-
I have a classic ASP web site that has been running flawlessly for at least 6 years now. I updated Windows Server 2003 to SP2 a few days ago, and now a "session counter" that I had implemented in Global.asa no longer works. Here is the code. From Global.asa:
function Application_OnStart()
{
Application("Visitors") = 0;
}function Session_OnStart()
{
Application.Lock();
{
Application("Visitors") = Application("Visitors") + 1;
}
Application.Unlock();// remainder of this function omitted, as it is irrelevant
}
function Session_OnEnd()
{
Application.Lock();
{
iVisitors = Application("Visitors");
if( iVisitors > 0 )
{
Application("Visitors") = iVisitors - 1;
}
else
{
Application("Visitors") = 0;
}
}
Application.Unlock();
}It appears to me that Session_OnEnd is never being called now, because Application("Visitors") keeps incrementing with each session BUT never deincrements since installing SP2! The code is so simple, that I can't see any reason why it is not doing so. Can anyone see a flaw in my code? Or am I just hosed? :(
There are certain session types that do not call Session end. Along with that the session doesn't end until it timesout. So if your session timeout has recently changed that could be the issue as well. Here is the MS help on it: The Session_OnEnd Event You can handle the Session_OnEnd event by adding a subroutine named Session_OnEnd to the Global.asax file. The Session_OnEnd subroutine is run when the Abandon method has been called or when the session has expired. A session expires when the number of minutes specified by the Timeout property passes without a request being made for the session. The Session_OnEnd event is supported only when the session state Mode property is set to InProc, which is the default. If the session state Mode is StateServer or SQLServer, then the Session_OnEnd event in the Global.asax file is ignored. If the session state Mode is set to Custom, then support for the Session_OnEnd event is determined by the custom session-state store provider. You can use the Session_OnEnd event to clean up session-related information such as information for a user that is tracked in a data source by the SessionID value. Hope that helps. Ben
-
There are certain session types that do not call Session end. Along with that the session doesn't end until it timesout. So if your session timeout has recently changed that could be the issue as well. Here is the MS help on it: The Session_OnEnd Event You can handle the Session_OnEnd event by adding a subroutine named Session_OnEnd to the Global.asax file. The Session_OnEnd subroutine is run when the Abandon method has been called or when the session has expired. A session expires when the number of minutes specified by the Timeout property passes without a request being made for the session. The Session_OnEnd event is supported only when the session state Mode property is set to InProc, which is the default. If the session state Mode is StateServer or SQLServer, then the Session_OnEnd event in the Global.asax file is ignored. If the session state Mode is set to Custom, then support for the Session_OnEnd event is determined by the custom session-state store provider. You can use the Session_OnEnd event to clean up session-related information such as information for a user that is tracked in a data source by the SessionID value. Hope that helps. Ben
Yeah, I'm aware how sessions work. Unfortunately, unless I'm mistaken, the MS Help information above applies only to the ASP.NET Global.asax... while I'm using the classic ASP Global.asa. Thanks for your help though. I do appreciate it. I'll try digging deeper.
-
There are certain session types that do not call Session end. Along with that the session doesn't end until it timesout. So if your session timeout has recently changed that could be the issue as well. Here is the MS help on it: The Session_OnEnd Event You can handle the Session_OnEnd event by adding a subroutine named Session_OnEnd to the Global.asax file. The Session_OnEnd subroutine is run when the Abandon method has been called or when the session has expired. A session expires when the number of minutes specified by the Timeout property passes without a request being made for the session. The Session_OnEnd event is supported only when the session state Mode property is set to InProc, which is the default. If the session state Mode is StateServer or SQLServer, then the Session_OnEnd event in the Global.asax file is ignored. If the session state Mode is set to Custom, then support for the Session_OnEnd event is determined by the custom session-state store provider. You can use the Session_OnEnd event to clean up session-related information such as information for a user that is tracked in a data source by the SessionID value. Hope that helps. Ben
I created a new blank web site that has ONLY the following 2 files in it: =========== DEFAULT.ASP ===========
<html>
<body>
Sessions: <%= Application("Visitors") %>
</body>
</html>=========== GLOBAL.ASA ===========
<SCRIPT LANGUAGE=JScript RUNAT=Server>
function Application_OnStart()
{
Application("Visitors") = 0;
}
function Session_OnStart()
{
Application.Lock();
{
Application("Visitors") = Application("Visitors") + 1;
}
Application.Unlock();
}
function Session_OnEnd()
{
Application.Lock();
{
iVisitors = Application("Visitors");
if( iVisitors > 0 )
{
Application("Visitors") = iVisitors - 1;
}
else
{
Application("Visitors") = 0;
}
}
Application.Unlock();
}
</SCRIPT>... and absolutely NOTHING else. I also adjusted the session length from 20 minutes to 2 minutes (for the purposes of testing). Same thing... the value of
Application("Visitors")
keeps incrementing with each new session, but NEVER deincrements. As mentioned, all of this has worked flawlessly for years upon years... but after installing SP2 to Windows Server 2003... all of a sudden it is broken. I don't see anyway to fix this. Which blows. Any ideas? -
I have a classic ASP web site that has been running flawlessly for at least 6 years now. I updated Windows Server 2003 to SP2 a few days ago, and now a "session counter" that I had implemented in Global.asa no longer works. Here is the code. From Global.asa:
function Application_OnStart()
{
Application("Visitors") = 0;
}function Session_OnStart()
{
Application.Lock();
{
Application("Visitors") = Application("Visitors") + 1;
}
Application.Unlock();// remainder of this function omitted, as it is irrelevant
}
function Session_OnEnd()
{
Application.Lock();
{
iVisitors = Application("Visitors");
if( iVisitors > 0 )
{
Application("Visitors") = iVisitors - 1;
}
else
{
Application("Visitors") = 0;
}
}
Application.Unlock();
}It appears to me that Session_OnEnd is never being called now, because Application("Visitors") keeps incrementing with each session BUT never deincrements since installing SP2! The code is so simple, that I can't see any reason why it is not doing so. Can anyone see a flaw in my code? Or am I just hosed? :(
Try to put something in the session object:
Session("Test") = 42
This will keep the session object alive. I think that it might be a change in how the server handles session objects. If they don't contain anything they are discarded immediately without triggering a Session_OnEnd. The session id is kept by the browser, so when the user returns a new session object with the same id will be created. As it's a recreated session object, it probably doesn't trigger a Session_OnStart.--- single minded; short sighted; long gone;
-
Try to put something in the session object:
Session("Test") = 42
This will keep the session object alive. I think that it might be a change in how the server handles session objects. If they don't contain anything they are discarded immediately without triggering a Session_OnEnd. The session id is kept by the browser, so when the user returns a new session object with the same id will be created. As it's a recreated session object, it probably doesn't trigger a Session_OnStart.--- single minded; short sighted; long gone;