Session state can only be used when enablesessionstate is set to true

I got the following error when I try to load aspx page which is loading user control (ascx)
I'm trying to set a session variable in my user control and I get the below error over that step.

I did page enabled =true on my aspx page, web.config and checked IIS the ASP.Net session is enabled. What else can be checked.

I have like this in my web.config file -

"<pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" validateRequest="false" clientIDMode="AutoID" pageParserFilterType="Microsoft.SharePoint.ApplicationRuntime.SPPageParserFilter, Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" asyncTimeout="7">"


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 <configuration>\<system.web>\<httpModules> section in the application configuration.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Add these lines in web.config with in the <system.web> section

<sessionState mode="InProc" timeout="60" cookieless="false" >
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>

Hope this may helps.
Rainer JeschorCommented:
this is true for "normal" ASP.NET applications, but not recommended for SharePoint - especially not for SharePoint 2013!

First of all in SharePoint your normally have multiple Web Frontend Servers - therefore InProc mode should never be used.

Second, SharePoint has builtin its SessionState Servivce. To Enable Session State just open the SharePoint Management Powershell and run:
Enable-SPSessionStateService -DefaultProvision

This will create everything you need and also sets the appropriate entries in the web.config.

General SessionStateService configuration through Powershell commandlets:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SharePoint

From novice to tech pro — start learning today.