Why does debugging keep timing out in IIS7?

When I am debugging on my Windows 7 IIS7 machine, I get this error during a debug:

The web server process that was being debugged has been terminated by IIS. this can be avoided by configuring application pool setting in IIS. see help for further details.

What am I doing wrong?


Solution 1:

When you are debugging, IIS will not service any other requests until you are done stepping through your code. That includes the "ping" request that IIS sends to itself. Since IIS doesn't hear back from itself, it decides to shut itself down, which promptly terminates your debugging.

The solution is to increase the Ping Maximum Response Time in the application pool settings from its default value of 90 seconds. Set it to something high enough that will give you enough time to debug your code (like maybe 300 seconds).

Microsoft has a long-winded write-up here.


Edit: Others have suggested setting "Ping Enabled" to false. There are several reasons why I prefer to keep it in place, just with a larger interval, but the most important is that you will (most likely) have worker processing pinging enabled on production, and you should strive to develop and debug under a configuration that is as close to production as possible. If you do NOT have ping enabled on production, then by all means disable it locally as well.

Solution 2:

http://weblogs.asp.net/soever/archive/2009/06/18/debugging-sharepoint-asp-net-code-smart-key-codes-disable-timeout.aspx

Your App Pool -> Advanced Settings -> Ping Enabled to False

Solution 3:

IIS has a health-checking feature which periodically checks to see if an IIS worker process is hung or otherwise unusuable. If a worker process is stopped in the debugger, it looks unhealthy from the perspective of IIS, and IIS kills it and spins up a new process.

To change this behavior (on your dev workstation-- don't want to disable this in production!) go to the IIS management tool, select the Application Pools node in the left pane, and right-click on the app pool that your app lives in, and choose "Advanced Settings". From there, in the "process model" section, set "Ping Enabled" to False. You may also want to set the idle timeout to be a very large number.

See this IIS.NET article for more discussion of this issue and a screenshot. See this TechNet article for how to set these settings via code/script outside the admin tool.