Microsoft KB Archive/242425

From BetaArchive Wiki
Knowledge Base


Using Session Objects with Session State Disabled Returns Type Mismatch Error

Article ID: 242425

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft Internet Information Services 5.0
  • Microsoft Internet Information Server 4.0



This article was previously published under Q242425

We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 6.0 running on Microsoft Windows Server 2003. IIS 6.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:

SYMPTOMS

When trying to use a session-level object or variable when session state is disabled, you may receive the following error message:

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'Session'
/scripts/sessiontest/test.asp, line XXX


CAUSE

This behavior is by design. The session object is not registered in the scripting name space, so any executing scripts do not understand it and return a "Type mismatch" error message.

MORE INFORMATION

The following steps will reproduce this behavior.

  1. Disable session state at the folder or site level:

    1. Select a Web site or folder in the Microsoft Management Console (MMC).
    2. Right-click the item and select Properties.
    3. Select the Directory or Home Directory tab.
    4. Click Configuration or Create, and then click Configuration.
    5. Select the App Options tab
    6. Clear the Enable Session State box.
    7. Click OK to return all the way back to the MMC.
    8. Create a page in the application's physical folder named Sesstest.asp with the following contents:

      <% Session("strTest") = "Some Text" %>
                                  
    9. Browse the page. You should see the error.
  2. Disable session state at the page level:

    1. Highlight a Web site or folder in the MMC.
    2. Right-click the item and select Properties.
    3. Select the Directory or Home Directory tab.
    4. Click Configuration or Create and then click Configuration.
    5. Select the App Options tab.
    6. Select the Enable Session State check box.
    7. Click OK to return all the way back to the MMC.
    8. Create a page in the application's physical folder named Sesstest.asp with the following contents:

      <% @EnableSessionState = False %>
      <% Session("strTest") = "Some Text" %>
                                  
    9. Browse to the page. You should see the error.



Additional query words: iis asp

Keywords: kbprb kbpending KB242425