Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with the Session variable for ASP.NET

Reply
Thread Tools

Problem with the Session variable for ASP.NET

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      02-18-2005
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
www.nathansokalski.com


 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      02-19-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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
> (E-Mail Removed)
> www.nathansokalski.com
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System Session Variable VS. Own-declared 'Session' Variable chowchho ASP .Net 7 03-28-2008 02:38 PM
Session Timeout problems-web.confg session state and IIS session s =?Utf-8?B?Um9iSEs=?= ASP .Net 4 04-11-2007 04:52 PM
s there a way to set a session variable by session ID? admiller97@gmail.com ASP .Net 1 11-14-2005 05:13 PM
Session State - What does it take to establish one single ASP.NET session per "browser session" Jeff Smythe ASP .Net 3 01-02-2004 04:10 AM
How can I "know" the difference between a session timed out and a session that did session.abort? Jazzis ASP General 2 09-23-2003 07:16 AM



Advertisments