Session State not maintained asp.net 2.0

G

Guest

I must be doing something fundamentally wrong here. This is what I have in
web.config:

<sessionState cookieName="SOMENAME" mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data
source=127.0.0.1;user id=sa;password="
cookieless="false" timeout="15" />
<globalization requestEncoding="ISO-8859-1"
responseEncoding="ISO-8859-1" />
<pages theme="DefaultTheme" enableSessionState="true"
enableViewState="true" enableViewStateMac="true" validateRequest="true" />

I also set the EnableSessionState on the pages explicitly. In one of the
pages I have this code:

protected void Page_Load(object sender, EventArgs e)
{
if (Session["AAAAA"] == null)
{
Session["AAAAA"] = 0;
}
else
{
Session["AAAAA"] = (int)Session["AAAAA"] + 1;
}
}

If I keep refreshing this page, the Session ID is always different and the
Session.IsNewSession is always true. Even though I can see that the value of
0 is set, on every request the session is regenerated... Why would that
happen?

Thank you,

Iulian
 
V

Vivek N

Well I guess you need to add the GLOBAL.ASAX file in the root directory
of your website.
This is not automatocally added noe in VS.Net 2005 and so you need to
add this manually.

Add New Item --> Global.asax

You don't need to wirte any code. But I hope this should help you out.

Vivek N
MCAD
 
G

Guest

Ok, I solved it, apparently this was causing the problem:

<sessionState [...] />

Once I removed it from web.config it started to work. This was a
reminescence of the asp 1.1 application and I assume it conflicts with 2.0...
 

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,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top