A lot of developers might have seen following dialog box while debugging any web application in Microsoft Visual Studio.
“The web server process that was being debugged has been terminated by Internet Information Services (IIS). This can be avoided by configuring Application Pool ping settings in IIS. See help for further details.”
This issue happens when you have hosted your web application in IIS and have attached the debugger to the worker process.
While debugging, you might stop at any particular line for some long time for any reason say some calculation, quick watch window etc, so when debugger stops execution of the code, Internet Information Services (IIS) assumes that worker process has stopped responding and terminates that worker process. Subsequently, Visual Studio will show this dialog box since it’s debugger was attached to that process. So question might arise how does IIS gets to know if any process is stopped or is hung? Answer to this question lies in the solution explained below.
When we host any application in the IIS, most of the times, we do not change the default settings and our application inherits settings defined at the IIS level. Here are two such settings which can cause above issue if not set properly. To change these settings, follow below steps.
1. Launch IIS manager, select application pool of the website, click on advanced settings.
2. You will see following dialog box. You see following two settings. You can use any one of the below given settings to resolve this issue.
a. Ping Enabled –> Set to False
b. Ping Maximum Response Time –> Set some higher number.
Ping Enabled: This feature is for monitoring and improving application pool health by having the Windows Process Activation Service (WAS) ping an application pool’s worker process at set intervals. Setting it turned off will stop IIS from checking whether the worker process is still running or if this is hung, which will stop IIS from reporting it.
Explanation: If true, the worker process(es) serving this application pool are pinged periodically to ensure that they are still responsive. This process is called health monitoring.
Ping Maximum Response Time: This will increase the waiting time of a Ping request, IIS will wait for.
Maximum time that a worker process is given to respond to a health monitoring ping. If the worker process does not respond, it is terminated.
Above two settings make sure that IIS is aware of the current state of the worker process. Hence, above settings can be manipulated as per application performance but should not be disabled completely in production environments.
Note: These settings should not be changed in Production environment.
Why these settings should not be changed:
These settings are meant for health monitoring, reporting and to enable the WAS process to kill/restart the worker process whenever this is unhealthy. Whenever worker process is not healthy, this should be killed and also reported. If you disable this ping feature or increase this response time, requests will be waiting for the process to come responsive and your website performance will be hit.
Please let me know if you have any questions.