Planetside Software Forums

General => Open Discussion => Topic started by: rcallicotte on June 23, 2008, 12:43:00 PM

Title: C# Session Variables and Static Variables
Post by: rcallicotte on June 23, 2008, 12:43:00 PM
If anyone out there knows anything about web programming with C#, do you know if a static variable can be accessed across sessions by default.  In other words, two people are accessing the web page that is using static variables.  Will the sessions isolate the static variables on both pages unique to each user or is there a danger that the static variables will cross over the sessions? 

The way I understand it, the session states are unique to the user, include the static variable data.
Title: Re: C# Session Variables and Static Variables
Post by: old_blaggard on June 23, 2008, 01:08:57 PM
Quote from: calico on June 23, 2008, 12:43:00 PM
web programming with C#
Ah, see, there's your problem.

::) ;D

Some solutions include:
http://www.php.net/
http://www.python.org/
http://www.ruby-lang.org/
http://www.perl.org/

Sorry, but C# doesn't make sense to me in this context.  If you need the performance that C# offers over these languages, it would almost be a better idea just to write the program in C as a desktop application (which would be faster) and write some kind of script to grab user input from the internet and launch the C program with the parameters you're given.

To answer your question, though, I know for a fact that PHP creates separate instances of static variables, and would expect the same to be true of C# as well.
Title: Re: C# Session Variables and Static Variables
Post by: rcallicotte on June 23, 2008, 01:18:45 PM
Thanks, o_b.  Don't have a choice right now.

The problem with C# is that static variables are alive as long as the application domain (AppDomain) is up or as long as the code on the page is not updated.  This means if I do -

static string strWow = "TG2 Rules the World"

In this case, the string strWow will keep this value potentially forever.  C# has a problem in this regard.  Clearly.  Anyway, what I need to understand is if this is true across sessions, which is in a completely different level in the OSI layers than the Presentation or Application.
Title: Re: C# Session Variables and Static Variables
Post by: Rhalph on June 23, 2008, 03:53:42 PM
Do a test? Use two different browsers at the same time, that should give you two different sessions, so you'll be able to figure out by yourself... No?
Title: Re: C# Session Variables and Static Variables
Post by: rcallicotte on June 23, 2008, 03:55:53 PM
@Rhalph, yes.  I'm working on that.  But, I was hoping somewhere Microsoft had clarified this important hole.   ;D
Title: Re: C# Session Variables and Static Variables
Post by: Will on June 23, 2008, 04:03:09 PM
when is Microsoft clear on anything?
Title: Re: C# Session Variables and Static Variables
Post by: rcallicotte on June 23, 2008, 05:32:44 PM
Point taken.  Excuse me while I throw up from nervous tension.   


Quote from: Will on June 23, 2008, 04:03:09 PM
when is Microsoft clear on anything?