title: Application_Start() is not getting fired in Global.asax
body: <p>This works fine locally, and in our QA servers. However, in one of our client servers, it appears that Application_Start() is not getting fired at all.</p>
  
  <p>My Application_Start() looks like this:</p>
  
  <pre><code>void Application_Start(object sender, EventArgs e)
  {
      EventLogging.LogEvent("Application_Start() fired in Global.asax.", EventLogging.LogLevel.Basic);
      Application["ApplicationName"] = "My Application Name";
      EventLogging.LogVerbose("Application_Start() - ApplicationName: " + (Application["ApplicationName"] ?? "NA"));
  }
  </code></pre>
  
  <p>In one of my code modules, I check for Application["ApplicationName"], and if it has a value, I start a long-running scheduler thread. The problem is that this Application["ApplicationName"] is never set by Application_Start().</p>
  
  <p>What I have tried so far:</p>
  
  <ol>
  <li>My ASP.NET website is pre-compiled, so I verified that <code>PrecompiledApp.config</code> is in the root directory of my website</li>
  <li>I verified that <code>App_global.asax.dll</code>, <code>App_global.asax.compiled</code> and <code>App_global.asax.pdb</code>are present in the bin directory.</li>
  <li>I verified that the app pool is running in classic mode</li>
  <li>I cleared the temporary ASP.net files</li>
  </ol>
  
  <p>My website's IIS app pool has the following properties:</p>
  
  <ol>
  <li>NET CLR version: v4.0</li>
  <li>Enable 32-Bit Applications = true</li>
  <li>managed Pipeline Mode = Classic</li>
  <li>Start Mode = OnDemand</li>
  </ol>
  
  <p>I am positive that there is some kind of a configuration on this server that is causing <code>Application_Start()</code> to not fire, but I'm not sure what it is.</p>
  
  <p>I have read and tried the suggested methods below, but had no luck so far:</p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/1632636/global-asax-not-loading-for-precompiled-asp-net-website">Global.asax not loading for precompiled asp.net website</a></li>
  <li><a href="https://stackoverflow.com/questions/39300257/application-start-is-not-being-called-in-iis">Application_Start is not being called in IIS</a></li>
  <li><a href="https://stackoverflow.com/questions/17091534/application-start-is-not-firing-in-iis">Application_Start is not firing in IIS</a></li>
  </ol>
  
  <p>This has been driving me crazy. Please help. Thanks!</p>
  
  <p>Edit: As you requested, here is my entire global.asax:</p>
  
  <pre><code>&lt;%@ Application Language="C#" Inherits="WebFramework.GlobalBase" %&gt;
  &lt;%@ Import Namespace="System" %&gt;
  &lt;%@ Import Namespace="System.Web" %&gt;
  &lt;%@ Import Namespace="System.Web.Http" %&gt;
  &lt;%@ Import Namespace="System.Web.Mvc" %&gt;
  &lt;%@ Import Namespace="System.Web.Routing" %&gt;
  &lt;%@ Import Namespace="System.Reflection" %&gt;
  
  &lt;script runat="server"&gt;
  
      void Application_Start(object sender, EventArgs e)
      {
          EventLogging.LogEvent("Application_Start() fired in Global.asax.", EventLogging.LogLevel.Basic);
          AreaRegistration.RegisterAllAreas();
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
  
          Application["ApplicationName"] = "My Application";
          EventLogging.LogVerbose("Application_Start() - ApplicationName: " + (Application["ApplicationName"] ?? "NA"));
      }
  
      void Application_End(object sender, EventArgs e)
      {
          //  Code that runs on application shutdown
      }
  
      void Application_Error(object sender, EventArgs e)
      {
          // Code that runs when an unhandled error occurs
      }
  
      void Session_Start(object sender, EventArgs e)
      {
          // Code that runs when a new session is started
  
      }
  
      void Session_End(object sender, EventArgs e)
      {
          // Code that runs when a session ends. 
          // Note: The Session_End event is raised only when the sessionstate mode
          // is set to InProc in the Web.config file. If session mode is set to StateServer 
          // or SQLServer, the event is not raised.
  
      }
  
      public override string GetVaryByCustomString(HttpContext context, string custom)
      {
          if (custom.ToLower() == "sessionid")
          {
              return context.Session.SessionID;
          }
          return base.GetVaryByCustomString(context, custom);
      }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Note: GlobalBase.cs is basically a cs file that does nothing.</p>