Thursday, March 14, 2013

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

I have a site collection which contains some web parts. After upgrading the relevant content database from SharePoint 2010 to SharePoint 2013, I rebuilt the web parts on SharePoint 2013 through Visual Studio 2012 (.Net Framework 4.5), and deployed them to that site collection.

However, the error below popped up.

"Sorry, something went wrong 

An unexpected error has occurred.

Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.

Technical Details

Troubleshoot issues with Microsoft SharePoint Foundation.

Correlation ID: 8a80079c-c732-3006-daf1-b07efcef7326

Date and Time: 14/03/2013 9:25:53 AM"

This doesn't tell us anything, but in SharePoint 2013 log file, I got more details:

"System.Web.HttpException: 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 \\ section in the application configuration.   
at System.Web.UI.Page.get_Session()"

This is weird, because I can see the "Session State Service" is running from Central Admin site.

However, in the Web Application web.config file, the "Session" module is not there.

Then, I checked the Session State Service status through PowerShell script Get-SPSessionStateService

So, in SharePoint 2013, the "Session State Service" is disabled by default!

To resolve this problem is easy, run PowerShell script: Enable-SPSessionStateService –DefaultProvision

And now, if we check the web.config file, the "Session" module is added there.

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

[update 2014-02-14]

As a quick fix, we can run the PowerShell scripts below to reset "Session State Service"

Enable-SpSessionStateService -DatabaseName SP_SessionState 


  1. Thank you very much. It was very useful. I finished first part without commands updated at 2014-02-14. So now how i can configure times like connection timeout or main important that we want to inform users after timeout.

  2. Could be your skype intercepting your requests at 80 port, in Skype options uncheck
    Or Your IE has connection checked for Proxy when there is no proxy
    Or your fiddler could intercept and act as proxy, uncheck it!
    Solves the above problem, It solved mine!