Tuesday 18 January 2011

How to Enable SessionState in SharePoint 2010?

You'd like to use session object in your code but you receive an error saying that by default it's disabled.

You'd need to make these changes in the web.config of your application:

1) add the SessionStateModule assembly
<add name="SessionState" type="System.Web.SessionState.SessionStateModule, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

2) Add a http module
<httpModules>
<add name="SessionState" type="System.Web.SessionState.SessionStateModule" />
</httpModules>

3) Enable session state
<pages enableSessionState="true" ... />

No comments: