473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

"Session state can only be used when enableSessionState is set to true" Error

Hi All,

In my application, I wished to check certain things on each page
load, so rather than paste the same code in each pages constructor, I
thought it would be more logical to inherit from Page and place the
code in there. Then each webpage will inherit from my modified page
class. This works fine, but if I try and access the Session[] from the
modified page class, I get 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.

Any help in resolving this would be greatly appreciated!

Thanks.

Feb 11 '07 #1
3 34430
Paul,
If you have this:

<pages enableSessionState="true" />

in your web.config, you should not be having an issue like this.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Paul" wrote:
Hi All,

In my application, I wished to check certain things on each page
load, so rather than paste the same code in each pages constructor, I
thought it would be more logical to inherit from Page and place the
code in there. Then each webpage will inherit from my modified page
class. This works fine, but if I try and access the Session[] from the
modified page class, I get 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.

Any help in resolving this would be greatly appreciated!

Thanks.

Feb 11 '07 #2
On 11 Feb, 15:45, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Paul,
If you have this:

<pages enableSessionState="true" />

in your web.config, you should not be having an issue like this.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
Hi Peter,

Even with that in the web.config, the exact same error occurs.
I'm using the Session object in many places through the project, but
the only time it errors like in my first post is when I put it in a
class which inherits from PAGE.
Feb 11 '07 #3
On 11 Feb, 17:22, "Paul" <Gef.Mongo...@gmail.comwrote:
On 11 Feb, 15:45, Peter Bromberg [C# MVP]

<pbromb...@yahoo.yabbadabbadoo.comwrote:
Paul,
If you have this:
<pages enableSessionState="true" />
in your web.config, you should not be having an issue like this.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

Hi Peter,

Even with that in the web.config, the exact same error occurs.
I'm using the Session object in many places through the project, but
the only time it errors like in my first post is when I put it in a
class which inherits from PAGE.
Solved it. Because I was inheriting from Page class, the child
constructor was being called before the base constructor. This means
the Session object hadn't been created yet. I placed the needed code
in an overriden OnLoad event and it all works fine.

Feb 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: bajopalabra | last post by:
hi session("myVar") = rs.getRows( ) don't work when number of records is greater than 10 does anybody know WHY ??? is it a Session object limitation ??? thanks
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
3
by: Jeff Smythe | last post by:
I simply want to execute some code once when a new session of my ASP.NET application is started (I'm not using session state for anything else - just writing some data to a database). I thought...
1
by: Bill Cohagan | last post by:
We are attempting to convert an already existing application over to using multiple worker processes; thus we need to store state via session state server rather than in process. Since this app...
0
by: keekaye | last post by:
This was working ok but I changed something and I don't know where but it's no longer working. I get "Could Not Start Session" error. I'm sure it's something obvious but this is my first stab at...
1
by: Axel Dahmen | last post by:
Hi, today I've had a strange DTS error: In one of my transformations I'd been using several Copy Column transformations + one ActiveX transformation using a lookup function. This lookup function...
13
by: dee | last post by:
Hi My code complies the following line: Session("passed") = 1 but puts wiggly error line under the second Session("passed") in the following expression: Session("passed") = Session("passed") +...
3
by: Arnold | last post by:
I am having problem loading the image from the database. It gives this error: "Invalid parameter used." This is my source code: Private abyt() As Byte Private fo As New OpenFileDialog Private sf...
1
by: =?Utf-8?B?QUcgTW9yZW5v?= | last post by:
I had a virus. Ran Norton Antivirus. Now when I start my computer I get "FTP Port is used" error message and no internet access, however, computer is connected to wireless home network. Any...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.