473,320 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with the Session variable for ASP.NET

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
1 1448
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nick Whitelegg | last post by:
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication script which checks a username/password. If the...
1
by: Jonathan Chong | last post by:
I have problem with AOL browser (IE and Netscape are OK) accessing my Web site after putting up a load balancer that will go to W1 or W2. The problem does not happen when there is only Web server...
3
by: Gary | last post by:
I am having a strange problem that I cannot solve. I have an asp page that I use for a user to login and gain access to other pages. When the user logs in I set a couple of session variables like...
1
by: farooqazeem | last post by:
Hi guys, I’m facing some problem can u solve it. Problem is: I’m giving user Id and password in (Login_sess.asp) and submit it to page (sess_test.asp). I am setting session variable...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
3
by: Philip Tepedino | last post by:
I'm having an odd problem. My website's session state is getting shared between users! This problem only happens when a user tries to access the site from inside our corporate LAN. The user,...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
13
by: Simon Matthews | last post by:
I am having issues with the right way to architecture the following (using c# asp.net):- The question I have is how best pass the collected data from one web page for use in another. The...
8
by: Nacho | last post by:
Hello people I have the following problem I have a private area in my site. The user enters the username and password, then clicks "enter" and the session is created and also a session...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.