Static Variables - Developers Anonymous
Tuesday, August 01, 2006 5:19 AM Trivium DawnWalker

Static Variables

OK!

Its official. Static variables are really really really evil. and naturally I found out the hard way. Now I have used static variables in a few places. Usually just to keep track of who has what permissions on the current page, the PrimaryKey of the entry they working on and so forth.

 To my surprise, we have discovered that these static variables are carried between user sessions. And by that I don't mean you log off and log back on and the variable still has a value.  I mean, that when a variable is assigned a value due to one of MY actions and YOUR variable then has the same value as mine if we are logged in at the same time and working on the same page.

 So if anyone has been wondering, STATIC VARIABLES ARE THE ROOT OF ALL EVIL IN ASP.NET!!!!!!!!!!!!!!!!!!

 I know this is my fault for not knowing my basics inside and out but I never thought that would be possible. Oh well, there's only another 9 projects I need to changed and re-deploy.

 

BTW: anybody wanting to know how the GAC works check out : http://graysmatter.codivation.com/MyGrandmotherAndTheGlobalAssemblyCacheAndStarWars.aspx

its a great article!

Filed under: ,

Comments

# re: Static Variables

Tuesday, August 01, 2006 8:52 AM by codingsanity

If you think they're evil now, check out the ThreadStaticAttribute, that'll REALLY mess you up on ASP.NET.

# re: Static Variables

Tuesday, August 01, 2006 2:44 PM by Craig Nicholson

LOL, thats the best way to learn Steven, the hard way. :)

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: