473,395 Members | 1,905 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,395 software developers and data experts.

SessionState won't work

I have notice a couple of other threads here that depict the same problem I
am having: I can't get session state to work.

I wrote a component class to do all of my database access and use it in both
Windows .net and ASP.net applications. I was dealing with it in a single
aspx page (using codebehind) where it worked fine for this particular app.

Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection string )

In one of the pages that uses this I have:
dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)

But this gets flagged with an error saying that session state can only be
used when enablesessionstate is set to true. I do have it set to true on
this page as follows:
<%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>

Also my web.config file says:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Any idea why this is not working
thanks,
Dean
Nov 17 '05 #1
5 1364
I put that second line in my session_start as you advised that says:
Session("myDBProc") = myDBProc
and I still get exactly the same error. Since I have seen this problem
posted before and also noticed than noone has been able to find a solution,
I suspect that maybe this is a bug in asp.net?

Trying something simpler I put the following into session_start:
dim sessioninteger as integer = 4
and tried to retrieve it from my aspx page - it came through as zero
Then,
I used your suggestion to follow that definition with:
session("sessioninteger") = sessioninteger
and it came through as 4, as it should.

(by the way, i don't see your suggestion in any docs or books - is this an
undocumented solution?)

so, it seems that it will work with simple value types but not with
something more complex.
Not sure I know where to go from here,
Dean

"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
Even in the global.asax you still need to place the connection into the
session variable.

Change your code to include setting the session variable and it will work:

Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection string )
Session("myDBProc") = myDBProc

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Dean" <de*********@earthlink.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have notice a couple of other threads here that depict the same problem
I
am having: I can't get session state to work.

I wrote a component class to do all of my database access and use it in

both
Windows .net and ASP.net applications. I was dealing with it in a

single aspx page (using codebehind) where it worked fine for this particular app.
Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection

ring )

In one of the pages that uses this I have:
dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)

But this gets flagged with an error saying that session state can only be used when enablesessionstate is set to true. I do have it set to true on this page as follows:
<%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>

Also my web.config file says:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Any idea why this is not working
thanks,
Dean


Nov 17 '05 #2
Ah, sorry for the last message, I got it to work as you suggested.
In the aspx pages where I use myDBProcs, of course I had to put:
dim myDBProc as PhotoDBProcs
and then I had to put the following in the Initializecomponent() routine:
myDBProc = CType(Session("myDBProc"), PhotoDBProcs)

Before I was just doing a
Dim myDBProc = CType(Session("myDBProc"), PhotoDBProcs)

Thanks so much for your help, it is working ok now.
Dean
"S. Justin Gengo" <sj*****@aboutfortunate.com> wrote in message
news:e5**************@TK2MSFTNGP11.phx.gbl...
Even in the global.asax you still need to place the connection into the
session variable.

Change your code to include setting the session variable and it will work:

Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection string )
Session("myDBProc") = myDBProc

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Dean" <de*********@earthlink.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I have notice a couple of other threads here that depict the same problem
I
am having: I can't get session state to work.

I wrote a component class to do all of my database access and use it in

both
Windows .net and ASP.net applications. I was dealing with it in a

single aspx page (using codebehind) where it worked fine for this particular app.
Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection

ring )

In one of the pages that uses this I have:
dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)

But this gets flagged with an error saying that session state can only be used when enablesessionstate is set to true. I do have it set to true on this page as follows:
<%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>

Also my web.config file says:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Any idea why this is not working
thanks,
Dean


Nov 17 '05 #3
Is your object PhotoDBProcs serializable?

"Dean" <de*********@earthlink.net> wrote in message
news:#L**************@tk2msftngp13.phx.gbl...
I have notice a couple of other threads here that depict the same problem I am having: I can't get session state to work.

I wrote a component class to do all of my database access and use it in both Windows .net and ASP.net applications. I was dealing with it in a single
aspx page (using codebehind) where it worked fine for this particular app.

Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection ring )
In one of the pages that uses this I have:
dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)

But this gets flagged with an error saying that session state can only be
used when enablesessionstate is set to true. I do have it set to true on
this page as follows:
<%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>

Also my web.config file says:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Any idea why this is not working
thanks,
Dean

Nov 17 '05 #4
If the object is in the local session storage he won’t be serialized.

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5
No, It is my understanding that serializable is only needed for
out-of-process state. In-proc should be ok for this app. Is my
understanding correct?
Dean
"Jerry" <JG******@rogers.com> wrote in message
news:iY*******************@news02.bloor.is.net.cab le.rogers.com...
Is your object PhotoDBProcs serializable?

"Dean" <de*********@earthlink.net> wrote in message
news:#L**************@tk2msftngp13.phx.gbl...
I have notice a couple of other threads here that depict the same problem
I
am having: I can't get session state to work.

I wrote a component class to do all of my database access and use it in

both
Windows .net and ASP.net applications. I was dealing with it in a

single aspx page (using codebehind) where it worked fine for this particular app.
Now I have the instantiation in global.asax in the session_start:
dim myDBProc as PhotoDBProcs = new PhotoDBProcs(...connection

ring )

In one of the pages that uses this I have:
dim myDBProc = ctype(Session("myDBProc"), PhotoDBProcs)

But this gets flagged with an error saying that session state can only be used when enablesessionstate is set to true. I do have it set to true on this page as follows:
<%@ Page Language="vb" EnableSessionState="true" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb" Inherits="DBAPhotoQuery.WebForm1"%>

Also my web.config file says:
<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>
Any idea why this is not working
thanks,
Dean


Nov 17 '05 #6

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

Similar topics

0
by: Phl | last post by:
Hi, I am having some problems hosting my website. Everything works fine in my local machine but when I upload to propduction server, my images somethimes won't load properly. I have my state...
2
by: ivanL | last post by:
In web.config, I can set SessionState mode to "Off" while using Forms authentication, they have 2 diff mechanisms, is this correct?
2
by: Philipp Schumann | last post by:
....BUT for _custom_ HttpHandlers. How can I do that? In my custom IHttpHandler, HttpContext.Current.Session is a null reference, and I can't use the session state. It is enabled in web.config...
7
by: Krishnan | last post by:
Hi, Could anyone please let me know how to read SessionState setting from the Web.Config file into an ASPNET application? TIA Krishnan
1
by: Randall Parker | last post by:
Does the SessionState timeout field in Web.config control how long a logged in session will stay logged in? For example, I want my users to be able to log in once during their work day and for...
0
by: =?Utf-8?B?RmFiaWFuIEFuZGVyc29u?= | last post by:
Hi WS Developers, I have am working on an integration project in which we are using WSDL and MS XML WebServices to integrate legacy systems other with external systems. Unfortunately, we must...
10
by: Nemisis | last post by:
Hi everyone, I am trying to create a custom error page, that the user gets shown when a error has occurred within my website. The code works perfectly, apart from when an invalid URL is typed...
0
by: somnathmali | last post by:
Suppose I have site xyz.com. Site has a page called show_user.aspx where I need to access the Session variables. But this show_user.aspx page will not be called directly Instead , when user type...
2
by: =?Utf-8?B?U3Bpcml0RmxhZw==?= | last post by:
I want to configure different sessionState on different subdirectory,so I wote this code in wen.config file: <location path="SubInProc"> <system.web> <sessionState mode="InProc"...
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: 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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...

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.