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:
<system.web>
<pages enableSessionState=”true” />
</system.web>
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.