Is it possible to debug Global.asax?

Mehdi picture Mehdi · Dec 25, 2009 · Viewed 38.6k times · Source

I can't debug global.asax file!

I have some codes in Application_Start() method but when I set a break point in the method, it is ignored!

Is this normal?

Answer

Patrick Lee Scott picture Patrick Lee Scott · Jan 26, 2011

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();

     // ...
}