473,614 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"Session state can only be used when enableSessionSt ate 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 enableSessionSt ate is set to true,
either in a configuration file or in the Page directive. Please also
make sure that System.Web.Sess ionStateModule 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 34459
Paul,
If you have this:

<pages enableSessionSt ate="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 enableSessionSt ate is set to true,
either in a configuration file or in the Page directive. Please also
make sure that System.Web.Sess ionStateModule 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...@yaho o.yabbadabbadoo .comwrote:
Paul,
If you have this:

<pages enableSessionSt ate="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...@g mail.comwrote:
On 11 Feb, 15:45, Peter Bromberg [C# MVP]

<pbromb...@yaho o.yabbadabbadoo .comwrote:
Paul,
If you have this:
<pages enableSessionSt ate="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
3656
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
4191
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 code for 6 hours and stops. I've found the problem to be the Set MySession = CreateObject("MAPI.Session")
3
2104
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 that I could simply put the code in the Session_Start event procedure in Global.asax.cs, however, the event procedure executes and a new session is created every time any page is requested - not just for the first page requested....
1
2398
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 previously used in process state there was little back pressure against storing objects in the session. Now we're paying the price because serialization sucks in referenced objects resulting in possibly huge state storage and serialize/deserialize...
0
1322
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 .net. Any help would be appreciated! Lisa Here is the live link and the error: http://www.noefc.info/events_calendar2.aspx
1
2246
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 uses a second connection to the same SQL server but to a different database. I'm using this function to populate a new column in a table with calculated values. The transformation didn't run, I got an "Transaction context in use by another...
13
1896
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") + 1 Why? Thanks Dee.
3
2575
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 As New SaveFileDialog Dim strCn As String = "Data Source=DATABASE\BARCA;" & _ "Initial Catalog=MIS;Integrated Security=SSPI" Dim cn As SqlConnection = New SqlConnection(strCn) Dim fs As IO.FileStream
1
3355
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 suggestions as to how to fix? Thank you
0
8182
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8579
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8279
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8433
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7093
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4052
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1747
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1425
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.