locked
Session state can only be used when enableSessionState is set to true error ? RRS feed

  • Question

  • Hi all
    I have acustom aspx page that uses session variables in the code
    It works fine on the development machine
    but when uploaded on the production server when I navigate tot the page it gives the following 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 <configuration>\<system.web>\<httpModules> section in the application configuration.

    I enabled session state from the web config by adding the http module
    <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
    and setting enableSessionState attribute of the <pages> element to true

    so what can be the reason for this.
    note: the production server is windows server 2008 r2
    there is no sql server installed on the production server, could that be the reason ?
    thanks
    Mina ------------- http://www.learn-mvc.blogspot.com/
    Thursday, January 21, 2010 11:52 AM

Answers

All replies

  • ok I got it
    just add this to web.config under safe controls section

     <PageParserPaths>
     <!-- To allow global: -->
     <PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
     </PageParserPaths>


    thanks
    Mina ------------- http://www.learn-mvc.blogspot.com/
    Thursday, January 21, 2010 1:00 PM
  • Where would the safe controls section be?
    Tuesday, February 1, 2011 3:46 PM
  • Hi,

       I have fixed this issue and made a post to share my solution.

    Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.

    In the end of the post,I gave a sample config.

     

    <?xml version="1.0"?>

    <configuration>

    <system.web>

        <sessionState mode="InProc" timeout="60" cookieless="false" ></sessionState>

    <httpModules>

    <add name="Session" type="System.Web.SessionState.SessionStateModule" />

    </httpModules>

    <pages enableSessionState="true" enableViewStateMac="true" enableEventValidation="true"  clientIDMode="AutoID">

    </system.web>

    </configuration>

     


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    微软WCF中文技术论坛
    微软WCF英文技术论坛

    Windows Azure中文技术论坛

    Monday, May 2, 2011 6:28 AM
  • Hey Frank,

    I am facing Similar Issue. Could you please provide an alternative link for your solution as I am unable to reach your solution? its showing as the site is temporarily down.

    Thanks,


    K.V.N.PAVAN

    Monday, May 14, 2012 12:51 PM
  • Hi Mina 

    you should change Web.Config File like Below : 

    find this node : 

     <modules runAllManagedModulesForAllRequests="true">

    .......

    </modules>

    And Add below node between it : 

     <add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition="" />

    & finished...

    Good Luck

    (Mohammad Bagher)


    MBS - social.technet.microsoft.com Forum

    Thursday, June 14, 2012 5:01 PM
  • 1. Could be your skype intercepting your requests at 80 port, in Skype options uncheck
    2. Or Your IE has connection checked for Proxy when there is no proxy 
    3. Or your fiddler could intercept and act as proxy, uncheck it!

    Solves the above problem, It solved mine! 

    HydTechie

    HydPhani

    Monday, August 26, 2013 4:37 PM
  • Hi ,

    I have fixed this issue by running 

    Enable-SPSessionStateService -DefaultProvision cmdlet, After running this command ,it does not show any message. But it worked, without changing global.asax.

    swathi

    Friday, November 1, 2013 1:09 PM
  • Solved my problem
    Tuesday, July 7, 2020 9:02 PM