0

I have a ASP.NET Visual Basics Web Application that runs on IIS 8 that needs to call Application_Start in Global.asax in order to initialize several variables. However, as far as I can tell, the method never gets called, through remote debugging or logging. The Application is run on Classic Mode.

If I run it locally on Visual Studio, I see it work

Chen
  • 103
  • 1
  • 9
  • 1
    This may help you: https://stackoverflow.com/questions/641148/application-start-not-firing – Jamal Aug 25 '20 at 20:34
  • @Jamal I have already looked into that, but the answer seems to address debugging. I'm pretty certain the application_start does get fired. – Chen Aug 25 '20 at 22:30
  • Why are you running the app in the "old" Classic mode not the Integrated mode? That could be the problem. – Jamal Aug 25 '20 at 23:19

1 Answers1

0

Application pool with Classic mode doesn’t have an impact on this feature. On my side, the application_Start event works properly.
Please ensure that App_global.asax.dll located in the BIN folder. We could clean, rebuild the project, and deploy it again. Moreover, during the Application_start event, we had better not write the IIS log or write/modify a database, this commonly leads to a permission issue, which seems not working.
Besides, you could verify the result by using the IIS log.

  public class Global : System.Web.HttpApplication
    {
        public static int a = 34;
        protected void Application_Start(object sender, EventArgs e)
        {
            a = a + 45;
        }
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Response.AppendToLog("Application BeginRequest...."+a.ToString());
        }
}

This will generate a line of record in the IIS log.

2020-08-26 05:49:10 ::1 POST /WebForm1.aspx Application+BeginRequest....79 8001 - vabqia969VM Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/84.0.4147.135+Safari/537.36 http://localhost:8001/WebForm1.aspx 200 0 0 3

Please refer to the below link for troubleshooting.
Application_start not working

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22