How to enable Session in a SharePoint 2010 Application page?
How to enable Session State in SharePoint 2010
So as a developer you may have come across the need to use the Session object along the way. What you’ve probably noticed is that you get an error message that indicates you should enable session state as well as configure your http session module for sessions:
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 web.config
In order to resolve this you should make two entries into your web.config (in this case the one located under: C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS) file and run an SP command:
The first is to ensure that enableSessionState is set to TRUE.
<pages enableSessionState=”true” enableViewState=”true” enableViewStateMac=”true” […]>
if you don’t have the pages directive you can add it the following one under the <configuration> -> <system.web> nodes:
<pages enableSessionState=”true” enableViewState=”true” enableViewStateMac=”true” >
</pages>
This is found under the <configuration> -> <system.web> nodes
The second is to ensure that you have enabled Session as an http module by addint the following lines under the <configuration> -> <system.web> nodes:
<httpModules> <add name = “Session ” type = “System.Web.SessionState.SessionStateModule ” /> </httpModules>
The third step is to run the following SP command line:
Enable-SPSessionStateService –DefaultProvision
This instruction needs to be executed in the SP 2010 Power shell otherwise it won’t work. Be sure to run the power-shell as an administrator otherwise it won’t work.
For more information please visit the references below
Love
Can we use Let's Encrypt, the free and open certificate authority?
Hola! gracias por la info, me sirvió el comando sacandole el nombre del server. En mi caso, fue una migración…
Yes 3rd option helped me too. I removed the WC key Values from config file then started working.
I know this is from 2014. But really, thank you!