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
Steps to Reproduce the Problem
- Start Visual Studio .NET.
- On the File menu, point to New, and then click Project.
- In the New Project dialog box, click Visual C# Projects under Project Types. Under Templates, click ASP.NET Web Application.
- 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.
- In the Solution Explorer, right-click WebForm1.aspx, and then click View Code.
- 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";
}
- 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. - 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. - Stop the debugger.
- 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