We have a .Net web application. Due to many reasons, I created a Public Class in App_Code folder. It has, among others:
Private Shared _AltPopNum As Integer
Public Shared Property AltPopNum() As Integer
Set(value As Integer)
_AltPopNum = value
Apparently, everything worked fine. A couple pages set this value, which can then be accessed in another couple pages. But recently, a case occured where this value was switched between users. That is, UserA inserted the value 10. Two seconds later, UserB inserted the value 15. When UserA read the variable, it was assigned as 15.
Now, I was under the impression that global class variables were stored pretty much like session variables, that is, they are linked to the username/computer. A user in one computer would have totally separate variables from those of another user in another computer. I decided to use this approach because these are short term variables (usually used within the next minute or two and then become useless) and I already had the class created for other methods. But if this isn't reliable, then I'd have to switch to keeping these values in a table and connecting to the database all the time, which I'd rather not do. Session variables would share the same problems, despite being shorter lived (we've tried to make them stay alive for more than 20 minutes, but utterly failed, despite trying various different solutions).
So, does anyone know why this is happening? Is this to be expected from using global variables? Or is this just some freak problem? Can it be solved via some settings, on .Net or IIS? Will I have to move these variables to a table in the DB? What should be the best approach?
EDIT: It should also be noted that this particular user kept having wrong values returned for some time (to my knowledge no other changes occured within seconds of it), then changed computer and, apparently, things worked fine.