SharePoint 2010 Enable Session State

If you trying to store data to session or using session in your user control, application page, webpart etc. then some time it may encounter an error below if session property not set to true in web.config.

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.....

first enable session state to true in web.config

<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 add name session to modules in web.config
 <modules runAllManagedModulesForAllRequests="true">
----
----
----

 <remove name="Session" />


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

Once you have made the modifications above to the web.config file you need to ensure that the State Service service application is running. You can check the status of this through Central Administation. 


Comments

Popular posts from this blog

C# Copy files from one server to another

Suppress StyleCop SA1600

Telerik Rad Grid Sorting