1

I am working on an ASP.NET application and caching some reference data. The code to create the cache is invoked in the application_start event in global.asax. My problem is that the application_start event is being invoked multiple times which slows the application access. To test the issue I reinstalled the application. The application_start event was fired on first access to the application (as expected) and again in about an hour even though I did not make any changes. I am not making any file system changes in the application's bin file, and the application pool is set to default recycle settings (1740 minutes), so I am not sure why the event is being invoked.

Thanks

klone
  • 2,005
  • 2
  • 16
  • 18
  • Have you tried adding an 'Application_End' in your global.asax and setting a breakpoint? You could grab the stack trace once that gets reached and then post it here. – BumbleB2na Jul 14 '11 at 18:10

2 Answers2

4

I would check the Idle Time-out setting (defaults to 20 minutes). If the site doesn't process any requests for 20 minutes, the worker process will shut down, therefore the next time you run the app thereafter, you will get another App Start event.

Keith
  • 5,311
  • 3
  • 34
  • 50
  • You were right. I set the idle timeout to zero in the app pool settings and it resolved the issue – klone Jul 20 '11 at 21:05
1

You could log reason for restart in Application_End method of Global.asax.cs, I am using this code :

protected void Application_End(object sender, EventArgs e)
{
  HttpRuntime runtime = (HttpRuntime)typeof(System.Web.HttpRuntime).InvokeMember("_theRuntime", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.GetField, null, null, null);

  string shutDownMessage = "";

  if (runtime != null)
  {
    shutDownMessage = Environment.NewLine + "Shutdown: " +
                      (string)runtime.GetType().InvokeMember("_shutDownMessage", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null) + 
                      Environment.NewLine + "Stack: " + Environment.NewLine +
                      (string)runtime.GetType().InvokeMember("_shutDownStack", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField, null, runtime, null);
  }
}
Antonio Bakula
  • 20,445
  • 6
  • 75
  • 102