1

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.

My Application_Start() looks like this:

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"));
}

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

What I have tried so far:

  1. My ASP.NET website is pre-compiled, so I verified that PrecompiledApp.config is in the root directory of my website
  2. I verified that App_global.asax.dll, App_global.asax.compiled and App_global.asax.pdbare present in the bin directory.
  3. I verified that the app pool is running in classic mode
  4. I cleared the temporary ASP.net files

My website's IIS app pool has the following properties:

  1. NET CLR version: v4.0
  2. Enable 32-Bit Applications = true
  3. managed Pipeline Mode = Classic
  4. Start Mode = OnDemand

I am positive that there is some kind of a configuration on this server that is causing Application_Start() to not fire, but I'm not sure what it is.

I have read and tried the suggested methods below, but had no luck so far:

  1. Global.asax not loading for precompiled asp.net website
  2. Application_Start is not being called in IIS
  3. Application_Start is not firing in IIS

This has been driving me crazy. Please help. Thanks!

Edit: As you requested, here is my entire global.asax:

<%@ Application Language="C#" Inherits="WebFramework.GlobalBase" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Http" %>
<%@ Import Namespace="System.Web.Mvc" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Reflection" %>

<script runat="server">

    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);
    }

</script>

Note: GlobalBase.cs is basically a cs file that does nothing.

Vin Shahrdar
  • 1,151
  • 1
  • 12
  • 30

1 Answers1

0

It was a Windows issue! After installing the latest Windows Server 2012 R2 updates, this issue is not happening anymore!

Vin Shahrdar
  • 1,151
  • 1
  • 12
  • 30