472,789 Members | 1,318 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Wierd session state error

In my web.config I added <pages enableSessionState="true">.

In each of my pages I also added EnableSessionState="True" to the Page
declaration.

(I didn't think this was necessary, but...)

Any reason why even though I did this I keep getting this error....

Server Error in '/abc' Application.
--------------------------------------------------------------------------------

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>\<httpModulessection in the
application configuration.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: 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
<configuration>\<system.web>\<httpModulessection in the application
configuration.

Source Error:

Line 3: Inherits System.Web.UI.Page
Line 4:
Line 5: Dim c As abcshoppingcart = Session("Cart")
Line 6:
Line 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Source File: F:\work-related\websites\abc\Projects.aspx.vb Line: 5

Stack Trace:

[HttpException (0x80004005): 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>\<httpModulessection in the application
configuration.]
System.Web.UI.Page.get_Session() +2634804
Projects..ctor() in F:\work-related\websites\abc\Projects.aspx.vb:5
ASP.projects_aspx..ctor() in
F:\work-related\websites\abc\Projects.aspx.vb:912304
__ASP.FastObjectFactory_app_web_kwdoldj8.Create_AS P_projects_aspx() +47
System.Web.Compilation.BuildResultCompiledType.Cre ateInstance() +32
System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) +119
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath) +33
System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
+40
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
+160
System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute()
+93
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +155

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053

Aug 18 '08 #1
4 2458
Is this the extent of your session state tag?
<pages enableSessionState="true">

If so, that is your problem. You have to specify what type of state (most
likely inProc here) and potentially set a few other values as well. Here is
an example of using SQL Server:

<sessionState
mode="SQLServer"
sqlConnectionString="data source=db1;user
id=db1User;password=password"
cookieless="false"
timeout="20"
/>

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"Cirene" <ci****@nowhere.comwrote in message
news:uf*************@TK2MSFTNGP05.phx.gbl...
In my web.config I added <pages enableSessionState="true">.

In each of my pages I also added EnableSessionState="True" to the Page
declaration.

(I didn't think this was necessary, but...)

Any reason why even though I did this I keep getting this error....

Server Error in '/abc' Application.
--------------------------------------------------------------------------------

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>\<httpModulessection in
the application configuration.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: 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 <configuration>\<system.web>\<httpModulessection in the
application configuration.

Source Error:

Line 3: Inherits System.Web.UI.Page
Line 4:
Line 5: Dim c As abcshoppingcart = Session("Cart")
Line 6:
Line 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Source File: F:\work-related\websites\abc\Projects.aspx.vb Line: 5

Stack Trace:

[HttpException (0x80004005): 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>\<httpModulessection in the
application configuration.]
System.Web.UI.Page.get_Session() +2634804
Projects..ctor() in F:\work-related\websites\abc\Projects.aspx.vb:5
ASP.projects_aspx..ctor() in
F:\work-related\websites\abc\Projects.aspx.vb:912304
__ASP.FastObjectFactory_app_web_kwdoldj8.Create_AS P_projects_aspx() +47
System.Web.Compilation.BuildResultCompiledType.Cre ateInstance() +32

System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) +119
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath) +33

System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
+40
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig) +160

System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute()
+93
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +155

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053


Aug 18 '08 #2
Instead of using a shoppingcart object in Session, have you tested with a
simple string value?

"Cirene" <ci****@nowhere.comwrote in message
news:uf*************@TK2MSFTNGP05.phx.gbl...
In my web.config I added <pages enableSessionState="true">.

In each of my pages I also added EnableSessionState="True" to the Page
declaration.

(I didn't think this was necessary, but...)

Any reason why even though I did this I keep getting this error....

Server Error in '/abc' Application.
--------------------------------------------------------------------------------

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>\<httpModulessection in
the application configuration.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: 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 <configuration>\<system.web>\<httpModulessection in the
application configuration.

Source Error:

Line 3: Inherits System.Web.UI.Page
Line 4:
Line 5: Dim c As abcshoppingcart = Session("Cart")
Line 6:
Line 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Source File: F:\work-related\websites\abc\Projects.aspx.vb Line: 5

Stack Trace:

[HttpException (0x80004005): 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>\<httpModulessection in the
application configuration.]
System.Web.UI.Page.get_Session() +2634804
Projects..ctor() in F:\work-related\websites\abc\Projects.aspx.vb:5
ASP.projects_aspx..ctor() in
F:\work-related\websites\abc\Projects.aspx.vb:912304
__ASP.FastObjectFactory_app_web_kwdoldj8.Create_AS P_projects_aspx() +47
System.Web.Compilation.BuildResultCompiledType.Cre ateInstance() +32

System.Web.Compilation.BuildManager.CreateInstance FromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) +119
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath) +33

System.Web.UI.PageHandlerFactory.System.Web.IHttpH andlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String physicalPath)
+40
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig) +160

System.Web.MapHandlerExecutionStep.System.Web.Http Application.IExecutionStep.Execute()
+93
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +155

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053



Aug 18 '08 #3
It works fine with a simple string. So the problem must be with storing the
object in Session. Any ideas why I can't do this?

the abcshoppingcart is basically defined as this...

Public Class abcshoppingcart
Public Customer as new abccustomer
Public Product as List(of abcproduct)
End Class

Any ideas? Thanks!

"Jeff Dillon" <je********@hotmailremove.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Instead of using a shoppingcart object in Session, have you tested with a
simple string value?

"Cirene" <ci****@nowhere.comwrote in message
news:uf*************@TK2MSFTNGP05.phx.gbl...
>In my web.config I added <pages enableSessionState="true">.

In each of my pages I also added EnableSessionState="True" to the Page
declaration.

(I didn't think this was necessary, but...)

Any reason why even though I did this I keep getting this error....

Server Error in '/abc' Application.
--------------------------------------------------------------------------------

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>\<httpModulessection in
the application configuration.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: 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 <configuration>\<system.web>\<httpModulessection in the
application configuration.

Source Error:

Line 3: Inherits System.Web.UI.Page
Line 4:
Line 5: Dim c As abcshoppingcart = Session("Cart")
Line 6:
Line 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Source File: F:\work-related\websites\abc\Projects.aspx.vb Line: 5

Stack Trace:

[HttpException (0x80004005): 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>\<httpModulessection in the
application configuration.]
System.Web.UI.Page.get_Session() +2634804
Projects..ctor() in F:\work-related\websites\abc\Projects.aspx.vb:5
ASP.projects_aspx..ctor() in
F:\work-related\websites\abc\Projects.aspx.vb:912304
__ASP.FastObjectFactory_app_web_kwdoldj8.Create_AS P_projects_aspx() +47
System.Web.Compilation.BuildResultCompiledType.Cre ateInstance() +32

System.Web.Compilation.BuildManager.CreateInstanc eFromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) +119
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath) +33

System.Web.UI.PageHandlerFactory.System.Web.IHttp HandlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String
physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig) +160

System.Web.MapHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute()
+93
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +155

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053




Aug 19 '08 #4
"Cirene" <ci****@nowhere.comwrote in message
news:OW**************@TK2MSFTNGP06.phx.gbl...
It works fine with a simple string. So the problem must be with storing
the object in Session. Any ideas why I can't do this?

the abcshoppingcart is basically defined as this...

Public Class abcshoppingcart
Public Customer as new abccustomer
Public Product as List(of abcproduct)
End Class

Any ideas? Thanks!

"Jeff Dillon" <je********@hotmailremove.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>Instead of using a shoppingcart object in Session, have you tested with a
simple string value?

"Cirene" <ci****@nowhere.comwrote in message
news:uf*************@TK2MSFTNGP05.phx.gbl...
>>In my web.config I added <pages enableSessionState="true">.

In each of my pages I also added EnableSessionState="True" to the Page
declaration.

(I didn't think this was necessary, but...)

Any reason why even though I did this I keep getting this error....

Server Error in '/abc' Application.
--------------------------------------------------------------------------------

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.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: 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 <configuration>\<system.web>\<httpModulessection in
the application configuration.

Source Error:

Line 3: Inherits System.Web.UI.Page
Line 4:
Line 5: Dim c As abcshoppingcart = Session("Cart")
Line 6:
Line 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Source File: F:\work-related\websites\abc\Projects.aspx.vb Line: 5

Stack Trace:

[HttpException (0x80004005): 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>\<httpModulessection in
the application configuration.]
System.Web.UI.Page.get_Session() +2634804
Projects..ctor() in F:\work-related\websites\abc\Projects.aspx.vb:5
ASP.projects_aspx..ctor() in
F:\work-related\websites\abc\Projects.aspx.vb:912304
__ASP.FastObjectFactory_app_web_kwdoldj8.Create_AS P_projects_aspx()
+47
System.Web.Compilation.BuildResultCompiledType.Cre ateInstance() +32

System.Web.Compilation.BuildManager.CreateInstan ceFromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp, Boolean noAssert) +119
System.Web.UI.PageHandlerFactory.GetHandlerHelper( HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath) +33

System.Web.UI.PageHandlerFactory.System.Web.IHtt pHandlerFactory2.GetHandler(HttpContext
context, String requestType, VirtualPath virtualPath, String
physicalPath) +40
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context, String
requestType, VirtualPath path, String pathTranslated, Boolean
useAppConfig) +160

System.Web.MapHandlerExecutionStep.System.Web.Ht tpApplication.IExecutionStep.Execute()
+93
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +155

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053;
ASP.NET Version:2.0.50727.3053





I think you problem is in this code (Line 5).

Line 3: Inherits System.Web.UI.Page
Line 4:
Line 5: Dim c As abcshoppingcart = Session("Cart")
Line 6:
Line 7: Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Question to you: When do you think Line 5 is executed. Answer "no clue" is
bad answer.

When you page (or any object) is created .NET runtime follows following
steps
1. Memory allocated for the object.
2. Memory is initialized according to the defaults or what you wrote (like
you did in line 5). so if you declared member variable Int it's initialized
with 0 unless you wrote Dim k as Int = 4
Then it's initialized with 4.
3. Constructor called.

Only after that object is 'declared' created and we or ASP.NET might start
working with it. IE assign member variables like Session, Page, Request,
Response...

The method PreInit called, then Init.....

so if you want to access Session object you must do it much later... Like in
Page_Load event for example.
George.
Aug 19 '08 #5

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

Similar topics

5
by: Phil Grimpo | last post by:
I have a very odd situation here. I have an administration page, where based on a users permissions, a recordset is called from the SQL server which has a list of paths to "Module Menus". Each of...
1
by: Dean | last post by:
PageOne.aspx has an image control. The imageURL of the image control points to ImagePump.aspx. ImagePump.aspx gets a bitmap out of a SQLServer database, puts in into a bitmap object and does a:...
9
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
0
by: nbdy9(nospam) | last post by:
I have a ASP.Net website (mobile). From time to time the browser popup the following message. Anyway to catch the error and redirect to my start page? saying, login.aspx? Thanks. ...
5
by: sdettmers | last post by:
Hi, Database: SQL Server Session: SQL Server Language: C# Application: ASP.Net I have created a login page which attempts to retrieve the users record from the database and I...
2
by: Dave | last post by:
I have an application running on a 3 server webfarm running Windows 2003 with SQLServer Session state. After running for several hours, I started getting the following error. When I access each...
4
by: Abi | last post by:
We able to generate this error in our test environment and were able to research this enough to understand that the issue is NOT with an abject that needs to be serialized but rather as the stack...
18
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
2
by: DC | last post by:
Hi, we are using ASP.Net 1.1 on eight servers with one session state server (the windows 2003 service). Too often we are getting the exception "Unable to make the session state request to the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.