How Do I Debug Global.asax

Posted by Michael Sundstrøm on 2020-11-19 20:14

Having an ol’ sk00l application that uses classic dotnet can be a challenge sometimes. Yesterday I ran into an issue that required me to debug the Application_Start() method of Global.asax.

The Application_Start did a bunch of stuff - herein bundle the client assets (CSS and JS files). But the content did not render. Since this runs on application start - hence before the process is running it is a bit of a pickle to attache to the IIS process for debugging.

To the rescue System.Diagnostics.Debugger!!

Setting this line at the top (or whereever I want to break into debugging) helped solve the problem.

    protected void Application_Start()
    {
        System.Diagnostics.Debugger.Launch();

        // YOUR START CODE
    }

Happy debugging :)