Microsoft KB Archive/273974

= PRB: Session_OnStart Event Fires When the EnableSessionState Directive Is Set to False =

Article ID: 273974

Article Last Modified on 4/25/2001

-

APPLIES TO


 * Microsoft Internet Information Services 5.0

-



This article was previously published under Q273974



SYMPTOMS
When the EnableSessionState directive is set to False in Active Server Pages (ASP) page, and you request this directive, the Session_OnStart event still executes the first time that the page is requested, and the ASPSESSIONID cookie is still set.

The following code shows the EnableSessionState directive set to False: <%@ Language=VBScript EnableSessionState=False %>   <% 'Server-Side code here. %>   In addition, if your Session_OnStart event references the Session object, and if you use Microsoft Visual Basic Scripting Edition (VBScript), you may receive the following error message:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'Session'

NOTE: This error does not recur unless you restart the application because subsequent requests for the ASP page, even from new sessions, do not cause the Session_OnStart event to run.



CAUSE
EnableSessionState=False disables the use of the Session object for the ASP page and disables serialization of concurrent requests to the same Session.

NOTE: By default, concurrent requests to the same Session are serialized; that is, only one request executes at a time. This avoids the problems that occur if two or more separate requests are writing data to the same Session object at the same time.



RESOLUTION
To fully disable Session for an ASP page, you must update the Internet Information Server (IIS) configuration. Because you cannot disable Session at a page level, you must disable it at a Virtual Directory/Web Application level as follows:
 * 1) Open the Internet Services Manager (MMC), and locate the Virtual Directory/Web Application whose Session state you want to disable.
 * 2) Right-click the Virtual Directory/Web Application, and then click Properties.
 * 3) On the Directory, Virtual Directory, or Home Directory tab, click Configuration.
 * 4) On the App Options tab, clear the Enable Session State object.
 * 5) Apply the changes.

To avoid the &quot;Type mismatch&quot; error, if you set EnableSessionState=False, and the Session_OnStart event references the Session object, you can test for IsObject(Session) as follows: Sub Session_OnStart If IsObject(Session) Then Session(&quot;Var&quot;) = &quot;Value&quot; End If End Sub

