title: How does ASP.NET know to create the ASP.NET_SessionId cookie if Session_Start is defined?
body: <p>I've done quite a bit of testing on this, and I'm thoroughly confused. It seems ASP.NET will generate an <code>ASP.NET_SessionId</code> cookie if the <code>Session_Start</code> method in the <code>MvcApplication</code> class is defined, even if I'm not using the <code>Session</code> variable anywhere. That seems odd, considering there doesn't have to be anything in the method's body.</p>
  
  <p>Example (Global.asax.cs):</p>
  
  <pre><code>using System.Web.Mvc;
  using System.Web.Optimization;
  using System.Web.Routing;
  
  namespace MyApplication
  {
      public class MvcApplication : System.Web.HttpApplication
      {
          protected void Application_Start()
          {
              AreaRegistration.RegisterAllAreas();
              FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
              RouteConfig.RegisterRoutes(RouteTable.Routes);
              BundleConfig.RegisterBundles(BundleTable.Bundles);
          }
  
          private void Session_Start() { } // this is all it takes to generate a SessionId (?)
      }
  }
  </code></pre>
  
  <p>Now, I'm confused for multiple reasons:</p>
  
  <ol>
  <li><p>How is the mere presence of the <code>Session_Start</code> function enough to generate a SessionId? I'm not utilizing the <code>Session</code> variable anywhere in the application, and the method is empty. </p></li>
  <li><p>The <code>Session_Start</code> method is private, and I'm obviously not calling it anywhere inside the class, so how does ASP.NET know when a session starts?</p></li>
  <li><p>How does anything outside of this class even know the <code>Session_Start</code> method exists, and to check for a SessionId cookie? It isn't a partial class, and it's explicitly marked <code>private</code>. </p></li>
  </ol>
  
  <p>I know these reasons sort of blend into one another, but I'm really at a loss as to how this works. </p>