ASP.NET - Launch debugger programmatically using debugger.launch

For last few months, I’s working in a large scale project which runs both Classic ASP and ASP.NET in parallel. While debugging, we used Attach Process of Visual Studio 2010 to attach w3wp.exe. But for some reason, the process was not attaching and I’s unable to debug my application.

After hours of digging, I came across a nice workout. You can programmatically launch the debugger as below:

using System.Diagnostics;
// launch the debugger and attach to current process

As a side-note, for Classic ASP/VBScript use stop keyword and for Javascript use debugger;

Note: What I have mentioned is only for testing/debugging purpose and do remove the above code before moving to production server.

Happy debugging!