Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. C# 'static' variables on the web?

C# 'static' variables on the web?

Scheduled Pinned Locked Moved C#
csharpquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LizardWiz
    wrote on last edited by
    #1

    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()

    S S J 3 Replies Last reply
    0
    • L 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()

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • L 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()

        S Offline
        S Offline
        S Sansanwal
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • L 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()

          J Offline
          J Offline
          Joshua Nussbaum
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups