Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


hi friends this is guru,

when assign the value to session, at the time this error is coming. i put enableSessionState="true" in my webconfig.

my webconfig code is given below:
<pages enablesessionstate="true">
    <httpmodules>
        <add type="System.Web.SessionState.SessionStateModule" name="Session" />
    </httpmodules>

in my source:

<%@ Page Language="VB" AutoEventWireup="false" enableSessionState="true" CodeFile="default.aspx.vb" Inherits="_Default" >
</pages>

Please help me.. thanks
Posted
Updated 17-Mar-20 2:12am
v3

Go through this article, it would help: Exploring Session in ASP.Net[^]

It's explained in the article about enabling/disabling the session.
 
Share this answer
 
Comments
Albin Abel 15-May-11 15:20pm    
Very informative article
I've been struggling with this...but in my case the solution was slightly different. After following all the instructions to modify Webconfig and all the other stuff, I still had the problem! I had the assignment to a session variable on the page constructor.
I ended up moving that part of the code to the OnLoad event of other control, and it worked!
I want to thing this is because the constructor is called before any other library where the functionality for session variables resides, thus not available yet at the constructor point.

Hope this helps to future generations! :)
 
Share this answer
 
I had breakpoints set in the constructor methods of the base page, and the main page. Please remove the breakpoints in the debugger and the problem dissappeared! If still not works then please avoid to read the Session object in a constructor.
 
Share this answer
 
v2
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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900