Problem with the Session variable for ASP.NET

N

Nathan Sokalski

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.
 
A

Alvin Bruney [MVP]

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
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top