While installing SharePoint, Session State is disabled by default. If you have used session in any farm solutions then you might face this error.

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.

We can resolved the issue in couple of ways as show:

1. Solution :

We can create a sesssion state database and enable session state service with below PS Script.

Enable-SPSessionStateService -DefaultProvision

OR

Enable-SPSessionStateService -DatabaseName "Session State Database" -DatabaseServer "localhost" -SessionTimeout 120

This example enables a ASP.NET session state on a SharePoint Server farm that uses a custom database name, database server, session time-out of 120 minutes, and Windows credentials (due to the lack of a DatabaseCredentials parameter).

2. Solution:

You can register session state handler module in IIS.

  1. Open Internet Information Services manager.
  2. Move to site where problem occurred.
  3. Open modules list of this site.
  4. Add session state handler like show on the following image (click on it):

You can go either way. There are other ways as well like changing web.config and adding session start module or changing enableSessionState value to true.

Kind Regards!!

By Rijwan Ansari

MVP, CSM, CSPO, MCP, MCTS. Sr. Software Developer. Expertise in ASP.NET MVC, Angular, AngularJs, .Net Core, C#.NET, Azure, Cognitive Services, Machine Learning, SharePoint, Azure Services, and tools, Requirement Analysis, Team Management, Pre-Sales and more. Ability to work independently and Team, handle pressure and meet commitment. Excellence Communication and adjust in any environment

One thought on “SharePoint: 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.”
  1. G’day . is this work with SP2019 visual web parts? I’m having the same issue even after registering the session state handler module in IIS.

Leave a Reply

Your email address will not be published. Required fields are marked *