ASP.NET Internals Spelunking

When I wrote the ASP.NET book I pretty much lived in Reflector 24/7 to figure out all the gory implementation details. Back then it would have been great to be able to simply set breakpoints in some of the low level classes like HttpRuntime or modules.

Fortunately this is now possible, here’s a quick walkthrough:

  • Set up your Visual Studio to work with the new .NET symbols. Also have a look at the various symbol loading options you have.
  • Open an ASP.NET app
  • Set a breakpoint somewhere in your code (e.g. in a Page_Load)
  • Let the debugger hit the breakpoint
  • Open the call stack window and navigate up the stack, e.g. to HttpRuntime.ProcessRequest or Page.ProcessRequest
  • Set a breakpoint (use HttpRuntime.Init or the (c)ctor to step through the whole initialization process)
  • Right click the breakpoint, select location and check the “Allow the source code to be different from the original version” option.
  • Debug again. The debugger should now hit the breakpoint in the ASP.NET infrastructure class
  • Depending on how early in processing you set the breakpoint, you may have to recycle the AppDomain to start over. Simply make a change to web.config and save to trigger recycling.


Happy spelunking ;)

This entry was posted in ASP.NET. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s