Problem with storing value in Session object/variable

A

Al Wilkerson

Hey guys,

I'm having problems with creating/storing a value in a session variable for
later retrieving on another page.
Here is the aspx page where I create/store the value

<%Session["type"]="programming";%>
<asp:HyperLink id="hlnkProgramming"Target="main"
NavigateUrl="CategoryResults.aspx">Programming</asp:Hyperlink>

In the CategoryResults.aspx page I just have a Datagrid, and in the
CategoryResults.aspx.cs file I want to retrieve the value as below, however
no session value is ever stored.

string lSql;

if(Session["type"].Equals("programming"))
{

lSql = "Select * from Products where type = 'Programming'";
}


I thought you can create/store a value in a session variable on any aspx
page, and then retrieve that in any page of your whole application.

Any ideas ?

Thanks,
Al
 
K

Karl Seguin

Al:
Don't know what to tell you other than it works for me. I turned tracing on
and checked Response.Wrote the session and everything worked...turn on
tracing and take a look...

Browser settings might be to blame...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
 
J

jlien

Session information is stored "InProc" by default. You can check the
web.config file to see if that is how it is setup for your application.
This means that the session information is stored within the aspnet
worker process (aspnet_wp.exe or w3wp.exe depending on your OS). If the
process is recycled for any reason that session information will be
lost. Also if your application is setup to run in a web garden or to
use multiple worker processes, session information would not be the
same amongst all the processes.

Take a look here for more information:
http://support.microsoft.com/kb/307598#2
 

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