application -vs- session variable newbie problem

T

tony collier

i have the of the following in my global.asax:



void Application_Start(Object Sender, EventArgs e)
{
Application["appname"]="";
}

void Session_Start(Object Sender, EventArgs e)
{
Session["sessname"]="";
}




I then have two pages:

session1.aspx


.....
void Page_Load(Object sender, EventArgs e)

{

string test1=(String)Application["appname"];
Response.Write(test1+"<BR>");
Application["appname"] = "changed";

string test2=(String)Session["sessname"];
Response.Write(test2+"<BR>");
Session["sessname"] = "changed";

}

</script>

<html>
<form><a href=session-test2.aspx>click</a></form>
</html>


and



session2.aspx

<script runat="server">
void Page_Load(Object sender, EventArgs e)

{

string test1=(String)Application["appname"];
Response.Write(test1+"<BR>");
Application["appname"] = "application";

string test2=(String)Session["sessname"];
Response.Write(test2+"<BR>");
Session["sessname"] = "session";

}

</script>

<html>
<form><a href=session-test1.aspx>click</a></form>
</html>



the application variable works fine and starts as "", then becomes
"changed " then "application" and carry's on toggling as i jump between
pages, but the session variable can only be read and doesn't write back
when i try to change it's value. As it starts as "" it is never
displayed. Can someone tell me what i am doing wrong. thanks
 
T

tony collier

sussed it - it was because i had "cookieless=false" in web.config but i
wasn't set up to allow cookies :(
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top