Click here to Skip to main content
15,891,734 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone! I would like to ask you a question that is perhaps a little unusual but which I cannot answer, perhaps because I lack certain bases.

I state that we are talking about ASP.NET web application in C #.

The question is this: if I have a web application that performs calculations using common variables, whether these are static or not, and this application is accessed by multiple users from different locations via a usual URL, eg. www.mysite.com/application.aspx, can it ever happen that a user get the variable V1 modified by another user? Let me explain better: the "application.aspx.cs" class performs the sum of the values entered in two variables, V1 and V2; user 1 populates the variables as follows: V1 = 5 and V2 = 4; in the meantime, a user 2 connected to the same application www.mysite.com/application.aspx from who knows where in the world, is performing the same sum but has entered V1 = 3 and V2 = 7; in short, can it happen that the variables as populated by user 1 are overwritten by user 2?
If this is not possible (as I hope) can you explain to me why?

I hope I have explained clearly.
Thank you.

What I have tried:

I've tried to create different folders, a folder for each user, to prevent this possibility.

Eg.:
www.mysite.com/user1/application.aspx
www.mysite.com/user2/application.aspx
Etc...
Posted
Updated 15-Jul-22 2:07am

No, it's nor possible with variables - each user has it's own session, and they are not shared. Indeed, they aren't even kept for long - after a default of 20 minutes each session will expire, and all data stored in it will be deleted. Variables go even quicker: they are deleted pretty much when the page is completely sent to the user's browser.

If you want to share info between users, you need to do it explicitly, via a database or similar.
 
Share this answer
 
To add to what Griff said, you might be interested in this CodeProject article about classic ASP.NET: ASP.NET's Data Storage Objects[^]
I'm not an ASP.NET expert, but it seems to me that you can get into trouble with static variables when users are changing the same variable.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900