title: Error using session in IIS 7
body: <p>After deployment of my website to IIS, I'm getting the following error message when trying to access a session:</p>
  
  <blockquote>
    <p>Session state can only be used when
    enableSessionState is set to true,
    either in a configuration file or in
    the Page directive. Please also make
    sure that
    System.Web.SessionStateModule or a
    custom session state module is
    included in the
    \\
    section in the application
    configuration.</p>
  </blockquote>
  
  <p>I access it in <code>Page_Load</code> or <code>PreRender</code> events (I tried both versions). With Visual Studio Dev Server it works without a problem. I tried both <code>InProc</code> an <code>SessionState</code> storage, 1 and multiple worker processes. I added a <code>enableSessionState = "true"</code> to my webpage explicitly.
  Here is part of <code>web.config</code>:</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;globalization culture="ru-RU" uiCulture="ru-RU" /&gt;
      &lt;compilation debug="true" defaultLanguage="c#"&gt;
          &lt;assemblies&gt;
              &lt;add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
              &lt;add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
              &lt;add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
              &lt;add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
              &lt;add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
              &lt;add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /&gt;
              &lt;add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
          &lt;/assemblies&gt;
      &lt;/compilation&gt;
      &lt;pages enableEventValidation="false" enableSessionState="true"&gt;
          &lt;controls&gt;
              &lt;add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
              &lt;add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;/controls&gt;
      &lt;/pages&gt;
      &lt;httpHandlers&gt;
          &lt;remove verb="*" path="*.asmx" /&gt;
          &lt;add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" /&gt;
      &lt;/httpHandlers&gt;
      &lt;httpModules&gt;
          &lt;add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add name="SearchUrlRewriter" type="Synonymizer.SearchUrlRewriter, Synonymizer, Version=1.0.0.0, Culture=neutral" /&gt;
          &lt;add name="Session" type="System.Web.SessionStateModule" /&gt;
      &lt;/httpModules&gt;
      &lt;sessionState cookieless="UseCookies" cookieName="My_SessionId" mode="InProc" stateNetworkTimeout="5" /&gt;
      &lt;customErrors mode="Off" /&gt;
  &lt;/system.web&gt;
  </code></pre>
  
  <p>What else do I need to do to make it work?</p>
  
  <p>I tried to monitor if IIS accesses the <code>aspnet_client</code> folder with <a href="http://en.wikipedia.org/wiki/Process_Monitor" rel="nofollow noreferrer">Process Monitor</a> and didn't get any access.</p>