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

When IIS is not configured properly after creating SharePoint application and there are web parts or features that use session you may get the following error: Unexpected error occured: System.Web.HttpException: 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.

Solution

As a solution you must 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):
    IIS: Set session state module
  5. Click OK, recycle application pool and refresh the page.

I am not very sure why SharePoint doesn’t enable this module by default as mostly default session state module is enough.


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

  • Please GEEKS!,
    Would you think somebody posted this question might have even checked this funda?

    To all sufferers of this problem, I have my findings here!
    1. I could reproduce this issue in IE browser(IE10) and FIREFOX(22), though I have great settings of all enabled..etc.etc… in my local code, WHEN IE settings in Connection Tab –> LAN settings have “Use PROXY Server for Localhost…” checkbox shown as CHECKED – without a VALID PROXY server setting…

    When I uncheck this In IE, the same code with DEFAULT Session settings, runs like HORSE!!

    Doom to all GEEKS OUT THERE…

    But for common people, IT WAS GIVING NIGHTMARES TO ME, hope I could save a few out of yours!

    Peace!

  • Alexander says:

    Thank you a lot!

  • Hydtechie says:

    Could be your skype intercepting your requests at 80 port, in Skype options uncheck
    Or Your IE has connection checked for Proxy when there is no proxy
    Or your fiddler could intercept and act as proxy, uncheck it!
    Solves the above problem, It solved mine!

    HydTechie

Leave a Reply

Your email address will not be published. Required fields are marked *