Click to search the site Click to log in
Online articles
Download free tools
Support pages, per product
Services
Frequently asked questions, per product
Tip / trick: how to debug the ASP.Net application shutdown code (Application_End application event)
Author: George Mihaescu
Published: June 3, 2007
Category: Quick tip
Notes: Only works in .Net 2.0 (will NOT work in .Net 1.x)
Description: Provides a very quick and simple solution to the problem of debugging the ASP.Net application shutdown code.
View count: 1,579
Comments: 2 Read comments or post your own

  Print viewOpens in new window
 ListControl Leaks Memory

How to debug the ASP.Net application shutdown code (Application_End application event)

 

By George Mihaescu

 

Summary: This article is a quick tip, describing a simple way to debug the code executed when an ASP.Net application is shut down, such as the Application_End event handler. The tip works only in .Net 2.0.

 

The problem: You have code executed when the application is shut down (such you’ve handled the Application_End event in Global.asax). You want to be able to set a breakpoint in that code and hit it.

 

The solution: The simplest solution I’ve found relies on the fact that starting with ASP.Net 2.0 the app domain is recycled when a subdirectory of the web application is renamed. Therefore:

  1. set the breakpoint you need in the application shutdown code
  2. start debugging in VS 2005
  3. in Windows explorer rename a subdirectory of the Web application (if you don’t have one, create one first). As a consequence of the subdirectory being renamed, the application domain will be recycled by the ASP.Net worker process and your breakpoint will be hit

 

 


Reader comments:
Name: (optional)
Verification text:    
(type as in image next to it)
Comment: max 2,000 characters; for security reasons no active content / no HTML formatting is supported.
Please stick to the subject of the article; comments are reviewed and unrelated / inappropriate ones will be deleted.

On Jan 31, 2010 at 3:05 EST realhossam said:

Thanks , simple and effective

On Jun 14, 2007 at 15:41 EST Simon said:

Awesome! Thanks so much for this simple but effective solution.
Copyright 2308 registered users, 24 users online now