C# – How to a breakpoint on Page_Load NOT get hit

.net-4.0asp.netc

I have a breakpoint set on a page's Page_Load event that never gets hit. There are no warning or messages indicating the breakpoint may never be hit, it just never gets hit even though the page is loaded successfully.

After a successful login, the user is redirected to this page using the login control's DestinationPageUrl property. As mentioned above, I can login and get to this page so at least that part works.

If I set a breakpoint on the Page_Load event of the Login page (just plain old ASP.NET sample Web Application stuff here), the breakpoint will get hit. I can step into the code but the page_load event never gets hit and the page just appears. In this sequence, I step through the page_load events of the login.aspx and site.master but not the page_load I really want to see.

Any suggestions? Thanks!

Best Answer

A couple possible answers here:

  1. You aren't actually going to the page you think you are. See Why is Page_Load not firing after coming back from another page using ASP.NET - ergo epic embarrassment :)

  2. The browser you are using has aggressively cached the page and isn't loading it. Make sure your browser of choice has ALL caching disabled.

  3. The page is inheriting from a base class which got rid of the onload event.

  4. The markup page is inheriting from a class different from the one you expect. (Happens a lot in copy / paste situations.)