Enable Session State in SharePoint 2010

Just Two entries we need to add in web.config file, when we use session state in SharePoint 2010 to store data for use in web parts, application page, etc. we may encounter the below given error if we not properly configured and enabled the session for the web application.

The error is :

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 \\<…

To fix this error and enable session state for SharePoint there are two entries we need to add for that web application.

First one – enable session state is set to True.

<pages enableSessionState=”true” enableViewState=”true” enableViewStateMac=”true” validateRequest=”false” pageParserFilterType=”Microsoft.SharePoint.ApplicationRuntime.SPPageParserFilter, Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” asyncTimeout=”7″>

Second One- we need to remove and add lines exist in the modules section for Session

 

<modules runAllManagedModulesForAllRequests=”true”>

<remove name=”Session” />

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

modules>

After modified the web.config file with above two entries, we need to ensure that the Sate Service application is running. This can be check through Central Administration.

Now session Sate is enabled for our web application.

About Krishana Kumar

Krishana Kumar is SharePoint Architect/Trainer having Architecture experience with high volumes at Enterprise level and global scale - creation of highly scalable solutions with global user base and geographically distributed architectural components. Good knowledge of SharePoint best practices and governance models. I hold Two Master degree in Computer Science with over 11 years of experience working on Microsoft Technologies specially SharePoint, Project, .NET and other Information Worker Technologies. Having good exposer in Client side scripting Angular.js, backbone and Node. I am currently responsible for SharePoint Infrastructure set up and leading teams in various medium and large scale projects, architecting, designing & installing SharePoint farms, developing custom components,, and providing advanced SharePoint administration and development training to teams and customers. I regularly speaks in various SharePoint User Groups and other Events. I have MCSA Windows Azure, MCSA Office 365, MCSE & MCSD SharePoint 2013, Microsoft Certified Developer (MCD) and holds MCPD, MCTIP and MCTS for SharePoint 2010, MCTS MOSS 2007 & WSS 3.0, MCPD, MCITP (EPM 2010 & 2007) and MCSD .NET.
This entry was posted in General Interest. Bookmark the permalink.