Dummy question: How to retrieve Session state Variable from another Page?

T

tuxedo

Hi, Gurus,
I have two web forms frm1 and frm2. In frm1, I wrote session("StudentID")=
textbox1.text in a button click event. And then, Response.redirect("...frm2")
In frm2, Page_load event, I tried both response.write session("StudentID") and
textbox2.text=session("studentID"), none of them showing me what I got from frm1.
I don't know why??
My web.config reads:
.....................



<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;user id=sa;password="
cookieless="false"
timeout="20"
/>
........................

Please help!!!


Thank you
 
T

tuxedo

Carl Prothman said:
Correction :
TextBox1.Text = DirectCast(Session("StudentID"), String)

Carl,
Thank you very much for you reply.
But I tried, still doesn't work.
Here is what I did:

Page1: button1 click event.
Session("StudentID")="12345"
Response.write session("Student")

It even works withoout DIRECTCAST on the same page.

IF I do:
Page1:
Session("StudentID")="12345"
Response.Redirect("http://Testweb/frmPage2.aspx")

Page2:
Page_load-----response.write(directcast(session("StudentID"),string))
or textbox1.text=directcast(session("StudentID"),string))
(----textbox1 is on page2----)


No error pops up but it does not show the 12345 either in the textbox
or on the left top side of the screen(I suppose this place is for
response.write)

Is this because thw way I used response.redirect?

Thank you
 
T

tuxedo

Carl, After I post last message, I tested it from a test machine by
opening the link and the page, it works!!!!!
Do you have any idea why I can see it working in .NET Development even
though I re-built the solution?

Thank you,
Tuxedo
 
C

Carl Prothman [MVP]

tuxedo said:
Carl, After I post last message, I tested it from a test machine by
opening the link and the page, it works!!!!!

Tuxedo,
Cool. I'm glad you got it working on at least one machine... ;-)

Do you have any idea why I can see it working in .NET Development even
though I re-built the solution?

ASP.NET Session requires that you have an IIS Application (not just a virtual directory)
with a global.asax file in the root. Plus your Web browser must be cookie enabled
to accept a Session cookie, otherwise you'll need to use Session-less cookies via
the web.config's "sessionState" tag.

Anytime you save changes to global.asax., web.config, machine.config,
you'll restart your IIS Application. Make sure your anti-virus software
is not "touching" these files.

--

Thanks,
Carl Prothman
Microsoft ASP.NET MVP
http://www.able-consulting.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top