C# 'static' variables on the web?
-
Does anyone know what exactly the term 'static' means in reference to web apps? Does this mean that there is only a single instance of the variable within the DLL itself and everyone who runs an instance of a particular page can modify the variable? If this is the case then how does one hold values in page level variables and have them maintain there value when the page posts back (for autopostback objects...)? Thanks in advance for anyone with a good explanation. ~LizardWiz()
-
Does anyone know what exactly the term 'static' means in reference to web apps? Does this mean that there is only a single instance of the variable within the DLL itself and everyone who runs an instance of a particular page can modify the variable? If this is the case then how does one hold values in page level variables and have them maintain there value when the page posts back (for autopostback objects...)? Thanks in advance for anyone with a good explanation. ~LizardWiz()
static is static across AppDomains. AFAIK, ASP.NET creates a separate AppDomain for each application and so everyone who runs a particular page must get the same value. I don't know if ASP.NET will unload appdomains during heavy load and reload them later, if that's true, then your static variables will be gone. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Does anyone know what exactly the term 'static' means in reference to web apps? Does this mean that there is only a single instance of the variable within the DLL itself and everyone who runs an instance of a particular page can modify the variable? If this is the case then how does one hold values in page level variables and have them maintain there value when the page posts back (for autopostback objects...)? Thanks in advance for anyone with a good explanation. ~LizardWiz()
Everyone who runs an instance of a particular page can modify the variable. Each session gets it own copy of shared property. Sanjay Sansanwal www.sansanwal.com
-
Does anyone know what exactly the term 'static' means in reference to web apps? Does this mean that there is only a single instance of the variable within the DLL itself and everyone who runs an instance of a particular page can modify the variable? If this is the case then how does one hold values in page level variables and have them maintain there value when the page posts back (for autopostback objects...)? Thanks in advance for anyone with a good explanation. ~LizardWiz()
If you are running your web application on multiple web servers, the static data will be local to each server 60% of statistics are made up on the spot