Losing session variable

S

Sari

Hi,

I've got two pages, page1.aspx and page2.aspx.
I've got a problem when I'm trying to access the
session variables in the second page. The session state is
null when I'm trying to get the values.

Code for page1.aspx
------------------------
Session.Add("str", "test");
Response.Redirect("Page2.aspx");

Code for page2.aspx
-------------------------
string str1 = Session["str"].tostring();


I don't know whats wrong. Please help!
Thanks,

Sari
 
A

Andy Mortimer [MS]

This link may contain the information you require

http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=7504

but you will want to

check your web.config, machine.config and your page directive to make sure
you have enabled session state.
Reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconsessionstate.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
ml/cpconpage.asp


You may also want to check that your aspnet process isn't recycling (there
will be an event log entry, check in task manager to see if the PID of the
process changes when you browse.)

I assume your web pages both live in the same sub directory under your web
root (i.e. the same web application)

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
 

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

Top