SessionState won't work

  • Thread starter Thread starter Dean
  • Start date Start date
D

Dean

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
 
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
 
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
 
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
 
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
 
Back
Top