473,386 Members | 1,830 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,386 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 2499
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.