Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1.9k views
in SharePoint Server by 30 37 42

I need to enable session state in SharePoint 2019, I already have many web parts which I need to consume session but I got this error

Application error when access /_layouts/15/employee.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.

I have a SharePoint 2019 farm with 4 servers! and I need to know where exactly should I enable session state in SharePoint 2019?


1 Answer

1 like 0 dislike
by 159 200 385
selected by
 
Best answer

How to Enable Session State in SharePoint 2019?

To enable session state in SharePoint 2019, you have to do the following:

  1. Backup the SharePoint web application configuration file "web.config".
    SharePoint Config file location
  2. Open the web.config with an editor tool like Notepad.
  3. Search for <pages enableSessionState.
    enable session state sharepoint 2019
  4. Set the enableSessionState to True.
  5. Save and close the web.config file.
  6. Go back to open the SharePoint 2019 Managent Shell as Administrator.
  7. Type the below command to enable SharePoint Session State service at Farm Level

     Enable-SPSessionStateService -DefaultProvision
    

    enable session state sharepoint 2019 using powershell

See also, Enable debugging in SharePoint Web.Config

If you don’t ask, the answer is always NO!
...