Is it possible to debug Global.asax?
- Attach the debugger to the IIS process.
- Open the global.asax file and put in a breakpoint.
- Add a space to the web.config file and save the file (this causes the current web application to reset);
- Refresh / goto a web page on the site.
- watch in amazement when the debugger stops at your breakpoint. :)
A simple way to break in Application_Start()
is to use the System.Diagnostics.Debugger
class. You can force the application to break by inserting System.Diagnostics.Debugger.Break()
where you would like the debugger to break.
void Application_Start(object sender, EventArgs e)
{
System.Diagnostics.Debugger.Break();
// ...
}