By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

Problem with the Session variable for ASP.NET

P: n/a
I am trying to increment the Session variable at certain points in my code,
but it will not work. The initial value assigned to it is always the one
that is displayed. Here is the code used to create and increment the Session
variable:

To create it:
Session.add("Right",0)

To increment it:
Session("Right")=Session("Right")+1

When the output is displayed, I always see 0, regardless of how many times
the incrementing code is executed (I know it is executed because the lines
immediately before and after it are executed). When I changed the creation
code to:

Session.add("Right",7)

I would see 7 as the output, so I always see the value assigned in the
creation statement, but I am unable to modify it. I have tried every idea I
could think of, but no success. If anyone has any ideas, I would greatly
appreciate it. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
www.nathansokalski.com
Nov 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Session["asdf"] = Int32.Parse(Session["asdf"].tostring()) + 1 will work with
a liberal dose of exception handling

--
Regards,
Alvin Bruney [Microsoft MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ http://www.lulu.com/owc
----------------------------------------------------------
"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:Ok**************@tk2msftngp13.phx.gbl...
I am trying to increment the Session variable at certain points in my code,
but it will not work. The initial value assigned to it is always the one
that is displayed. Here is the code used to create and increment the
Session variable:

To create it:
Session.add("Right",0)

To increment it:
Session("Right")=Session("Right")+1

When the output is displayed, I always see 0, regardless of how many times
the incrementing code is executed (I know it is executed because the lines
immediately before and after it are executed). When I changed the creation
code to:

Session.add("Right",7)

I would see 7 as the output, so I always see the value assigned in the
creation statement, but I am unable to modify it. I have tried every idea
I could think of, but no success. If anyone has any ideas, I would greatly
appreciate it. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
www.nathansokalski.com

Nov 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.