title: ASP.NET Business Layer Code Persists but I'm not sure where it's stored?
body: <p>I'm royally confused about ASP.NET now. I believed that everytime you retrieved a webpage business model referred to by that page would be created and that after the display had been sent to the user it would all be torn back down again.</p>
  
  <p>A colleague at work showed me this simple web app which seems to be storing business layer code between page fetches, without using session, cache, application, viewstate, querystrings, or post (as far as I can tell).</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>    &lt;form id="form1" runat="server" enableviewstate="False"&gt;
  &lt;div&gt;
      &lt;asp:Label ID="Label1" runat="server" Text="Label" EnableViewState="False"&gt;&lt;/asp:Label&gt;
      &lt;asp:Button ID="Button1"
          runat="server" Text="Button" EnableViewState="False" 
          CausesValidation="False" /&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Page Load:</p>
  
  <pre><code>            PersistanceTest.BLL.Singleton s = PersistanceTest.BLL.Singleton.GetInstance;
          Label1.Text = "Counter: " + s.GetCounter;
  </code></pre>
  
  <p>And Singleton class:</p>
  
  <pre><code>    public class Singleton
  {
  
      private int counter;
      private Singleton()
      {
          counter = 0;
      }
  
      private static Singleton theSingleton;
      static public Singleton GetInstance 
      {
          get 
          {
              if(theSingleton == null) 
              {
                  theSingleton = new Singleton();
              }
          return theSingleton;
          }
      }
  
      public int GetCounter
      {
          get
          {
              int c = counter;
              counter++;
              return c;
          }
      }
  }  
  </code></pre>
  
  <p>Now when I load the page, the counter increments each time I press the button. But I have no idea where the Singleton instance is being persisted in the framework? I was sure it wouldn't exist between page loads. Can someone shed some light on this? It's driving me crazy. </p>