'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.'
After getting above exception I added EnableSessionState="true" in my
page directive in my aspx page. But got same exception again then I added following code in my web.conf file:
Maybe you have multiple page and you don’t add the EnableSessionState with true to all the pages. You can also refer to the below link about the similar error.
mishra.bhupe...
Participant
1596 Points
378 Posts
enableSessionState
Mar 02, 2012 07:26 AM|LINK
Hi Friends.
I am getting exception on following code:
string val=Session.Contents["MyValue"].toString();
Exception thrown is:
'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.'
After getting above exception I added EnableSessionState="true" in my page directive in my aspx page. But got same exception again then I added following code in my web.conf file:
<pages enableSessionState="true" compilationMode="Auto" maintainScrollPositionOnPostBack="true">
But I am still getting same exception. What should I do??
Can any one help me??????????
Mahesh Darku...
Participant
896 Points
238 Posts
Re: enableSessionState
Mar 02, 2012 07:31 AM|LINK
do like this
string val=Session["MyValue"].toString();
mishra.bhupe...
Participant
1596 Points
378 Posts
Re: enableSessionState
Mar 02, 2012 07:40 AM|LINK
I have tried that. But still I got that exception. I don't think above exception has any relation with your given code.
Thanks.
Richey
Contributor
3816 Points
431 Posts
Re: enableSessionState
Mar 08, 2012 10:47 AM|LINK
Hi,
Maybe you have multiple page and you don’t add the EnableSessionState with true to all the pages. You can also refer to the below link about the similar error.
http://forums.asp.net/t/1724774.aspx/1
http://forums.asp.net/p/1722079/4603729.aspx/1?Enable+session+state