How to declare an application-wide static variable in ASP.net (VB)
Posted on 2011-10-27
Hi ASP.net (VB) experts,
for my ASP.net (VB) application I would like to declare a variable that is globally shared between all sessions, which will be used for some low-level system task. Just to make sure: I want that if one session changes the value, it is also changing in another session of the web site.
I have googled around, but many posts refer to "static" declarations, others to "global" or "shared", others yet mention that c# "static" is the same as vb "shared". Then I don't quite understand where (i.e. in which file in which directory, like App_Code etc.) and how (class or module or whatever) I should define such a variable. I'm totally confused.
Could someone please help me understand this and tell me how I can define a string variable named "status" that is accessible throughout the application, i.e. with the same shared content in all sessions? Some code example would be highly appreciated. (I am aware that I haven't fully understood the life-cycle and inheritance issues here, but for the time being, I'm happy with a kick-start on this globally-shared-variable-issue.)
Thank you in advance,