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

Research and Technology Lead | Software Architect | Full Stack .NET Expert | Tech Blogger | Community Speaker | Trainer | YouTuber. Follow me @ https://rijsat.com Md Rijwan Ansari is a high performing and technology consultant with 10 plus years of Software Development and Business Applications implementation using .NET Technologies, SharePoint, Power Platform, Data, AI, Azure and cognitive services. He is also a Microsoft Certified Trainer, C# Corner MVP, Microsoft Certified Data Analyst Associate, Microsoft Certified Azure Data Scientist Associate, CSM, CSPO, MCTS, MCP, with 15+ Microsoft Certifications. He is a research and technology lead in Tech One Global as well as leading Facebook community Cloud Experts Group and SharePoint User Group Nepal. He is a active contributor and speaker in c-sharpcorner.com community, C# Corner MVP and his rank at 20 among 3+ millions members. Additionally, he is knee to learn new technologies, write articles, love to contribute to the open-source community. Visit his blog RIJSAT.COM for extensive articles, courses, news, videos and issues resolution specially for developer and data engineer.

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 *