Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: Debugger Fails to Hit the Breakpoint When You Debug an ASP.NET Web Application a Second Time

View products that this article applies to.


When you debug an ASP.NET Web application, the debugger may successfully hit the breakpoint (on an erroneous line of code) only the first time. On subsequent runs, the debugger may fail to hit the breakpoint, and you receive a server error page.

↑ Back to the top


For performance reasons, the ASP.NET worker process, Aspnet_wp.exe (or W3wp.exe for applications run on IIS 6.0) caches the error information after the first debug session. If you try again to debug and do not make any changes in the code, the breakpoint is skipped. This behavior occurs because Aspnet_wp.exe determines that the code is redundant and then Aspnet_wp.exe displays only the cached error page.

↑ Back to the top


To resolve this issue, you need to force a reload of the pertinent .dll file into aspnet_wp.exe (or w3wp.exe for applications run on IIS 6.0). To do this, recompile the project before you debug again. However, the project cannot be recompiled unless you make changes to the code. Therefore, restart Microsoft Visual Studio .NET, and then click Rebuild All. (Alternatively, you can run the iisreset command from the command prompt.) Now, when you run the debugger again, it hits the breakpoint.

↑ Back to the top

More information

Steps to Reproduce the Problem

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialog box, click Visual C# Projects under Project Types. Under Templates, click ASP.NET Web Application.
  4. In the Location box, type TryDebug. If you are using the local server, you can leave the server name as http://localhost, so that the Location setting is http://localhost/TryDebug. Click OK to create the project.
  5. In the Solution Explorer, right-click WebForm1.aspx, and then click View Code.
  6. Copy and paste the following code after the Page_Load event handler in the WebForm1 class:
    private static System.String ss = WebForm1.StaticMethod();
    public static  String StaticMethod()
    	String s = null;
    	s.CompareTo( "hello" );  //put Break point here
    	return "Hello";
  7. Insert a breakpoint in the following line of code:
    s.CompareTo( "hello" );  //put Break point here
    To do this, select the specified line of code, and then press F9.
  8. Press F5 to run the debugger. When you hit the breakpoint, press F5 again. In the Exception dialog box, click Continue.

    You receive the error page in the browser.
  9. Stop the debugger.
  10. Press F5 to run the debugger again.

    This time, the debugger may not hit the breakpoint. Instead, you receive the cached error page in the browser. On subsequent debug attempts, you continue to receive the cached error page.

↑ Back to the top


For additional information about how to debug ASP.NET Web applications, click the article numbers below to view the articles in the Microsoft Knowledge Base:
306172 INFO: Common Errors When You Debug ASP.NET Applications in Visual Studio .NET
306169 PRB: Visual Studio .NET Debugger Does Not Stop on Breakpoints When You Debug ASP.NET Pages

↑ Back to the top

Keywords: kbdebug, kberrmsg, kbhttpruntime, kbide, kbprb, KB316970

↑ Back to the top

Article Info
Article ID : 316970
Revision : 8
Created on : 7/15/2003
Published on : 7/15/2003
Exists online : False
Views : 524