Problem with the Session variable for ASP.NET

Discussion in 'ASP .Net' started by Nathan Sokalski, Feb 18, 2005.

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

    www.nathansokalski.com
    Nathan Sokalski, Feb 18, 2005
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    >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
    >
    > www.nathansokalski.com
    >
    Alvin Bruney [MVP], Feb 19, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Smythe
    Replies:
    3
    Views:
    1,239
    Jeff Smythe
    Jan 2, 2004
  2. Ed
    Replies:
    7
    Views:
    2,748
    Saravana [MVP]
    Feb 2, 2004
  3. far asl via DotNetMonster.com

    How can i share asp session data with asp.net session data

    far asl via DotNetMonster.com, Mar 22, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    545
    =?Utf-8?B?VmliaHUgQmFuc2Fs?=
    Mar 23, 2005
  4. jnickfl1
    Replies:
    0
    Views:
    582
    jnickfl1
    Sep 18, 2006
  5. chowchho
    Replies:
    7
    Views:
    629
    Patrice
    Mar 28, 2008
Loading...

Share This Page