VS.NET can't break in global.asax / Application_Start ?

  • 219
  • 0
  • 2015-11-24

I got a break point on the first line of Application_Start(), but Visual Studio won't break in global.asax.cs ? 

Beacuse when VS.NET attaches to the process, Application_Start has already been running.
Do the following:

1. In Visual Studio (must be run as Administrator) set your breakpoint in global.asax.cs and start debugging as usual (F5). The page opens in your web browser, but the breakpoint isn't hit.

2. In Visual Studio, go to web.config, change it (e.g. enter a blank line somewhere) and save it. this lets the application pool recycle (and thus running through Application_Start in global.asax.cs the next time the web site is called) without killing the process you are attached to.

3. In your web browser, reload the page. The breakpoint should be hit now!