Search This Blog

Monday, March 30, 2015

Session state can only be used when enableSessionState is set to true error in SharePoint 2010

The full error message which comes as: 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 <configuration>\<system.web>\<httpModules> section in the application configuration.

Solution:
Approach-1:
- We have to enable session state for the pages by adding enableSessionState="truein the page directives.

- Then we need to modify in the web.config file like below:

Go to the <modules runAllManagedModulesForAllRequests="true">
Remove <remove name="Session" />

And add the below line:

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

Now Save this and it should work fine.

Approach-2:
Run the below PowerShell command:

Enable-SPSessionStateService –DefaultProvision

No comments:

Post a Comment