Session state can only be used when enableSessionState is set to true

I have a user control using session module in ASP.NET running on SharePoint 2010.

I configured the all the session settings which are:

  • Http Module


        <add name=”Session” type=”System.Web.SessionState.SessionStateModule” />


  • Pages directive

<pages enableSessionState=”true” …….

  • Modules

    <modules runAllManagedModulesForAllRequests=”true”>

    <remove name=”AnonymousIdentification” />

    <remove name=”FileAuthorization” />

    <remove name=”Profile” />

    <remove name=”WebDAVModule” />
    <remove name=”Session” />

    <add name=”SPRequestModule” preCondition=”integratedMode” type=”Microsoft.SharePoint.ApplicationRuntime.SPRequestModule, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />

    <add name=”ScriptModule” preCondition=”integratedMode” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ />

    <add name=”SharePoint14Module” preCondition=”integratedMode” />

    <add name=”StateServiceModule” type=”Microsoft.Office.Server.Administration.StateModule, Microsoft.Office.Server, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />

    <add name=”PwaAuthentication” type=”Microsoft.Office.Project.PWA.PwaAuthenticationModule, Microsoft.Office.Project.Server.PWA, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />

    <add name=”RSRedirectModule” type=”Microsoft.ReportingServices.SharePoint.Soap.RSRedirectModule, RSSharePointSoapProxy, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91″ />

    <add name=”PublishingHttpModule” type=”Microsoft.SharePoint.Publishing.PublishingHttpModule, Microsoft.SharePoint.Publishing, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />

    <add name=”Session” type=”System.Web.SessionState.SessionStateModule” preCondition=”” />


Now, the surprise…

I am able to set a value in the session , ex:

Session[“X”] = “my new value”;

But when reading the value, I got the following error:

Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.


Add the following line IN BOLD only


<SafeMode MaxControls=”200″ CallStack=”false” DirectFileDependencies=”10″ TotalFileDependencies=”50″ AllowPageLevelTrace=”false”>


    <PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />



One thought on “Session state can only be used when enableSessionState is set to true

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s