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:
- My ASP.NET website is pre-compiled, so I verified that
PrecompiledApp.config
is in the root directory of my website - I verified that
App_global.asax.dll
,App_global.asax.compiled
andApp_global.asax.pdb
are present in the bin directory. - I verified that the app pool is running in classic mode
- I cleared the temporary ASP.net files
My website's IIS app pool has the following properties:
- NET CLR version: v4.0
- Enable 32-Bit Applications = true
- managed Pipeline Mode = Classic
- 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:
- Global.asax not loading for precompiled asp.net website
- Application_Start is not being called in IIS
- 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.