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

1
  • 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. Commented Jul 14, 2011 at 18:10

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You were right. I set the idle timeout to zero in the app pool settings and it resolved the issue
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);
  }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.