Enable Session State in SharePoint

Hi all!

The other day I was configuring a serie of apps for SharePoint, but when we tried to access to them, we were receiving the following error:

Application error when access /_layouts/15/custom.aspx, Error=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() at…

So what happen here? By default the session state will not be enabled on the SharePoint Environment. To make our Provider Hosted App work properly, we need to enable the Session State.

So what we need to do is to change the web.config of the SharePoint web app:


<pages enableSessionState=”true” />


For our surprise, doing this was not enough, so we needed to execute the following PowerShell to enable the session at Farm Level:

Enable-SPSessionStateService -DefaultProvision

Lastly, we started the ASP.Net State Service en in Windows CMD Services. After following all this steps, we were able to continue with our applications.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s