IIS 7 and Above
Stop the w3wp process?
Last post Apr 23, 2010 10:19 AM by Rovastar
Apr 22, 2010 10:57 AM|ph08|LINK
We have an internal ASP.Net 3.5 application that opens Pervasive SQL databases, reads the data, and then closes the connection. Unfortunately, when the user exits the application, and even when they close their browser, the w3wp process seems to be holding
the PSQL database connections open, which is causing licensing issues for us. I would like the w3wp process to release the database connections once the last user has exited from the ASP.Net application.
How can I get w3wp to release the connections?
Someone told me that the Powershell command, "gps w3wp | kill" will stop the w3wp process. Is there any way I can automate this, so that the process will be killed automatically when the last user exits
our ASP.Net application?
Apr 22, 2010 10:53 PM|don.raman|LINK
From comand line you can type:
taskkill /F /IM w3wp.exe /T
This will kill w3wp.exe and all it's child process.
In order to call this from ASP.net application you can use
System.Diagnostics.Process. For further details look at
Apr 23, 2010 08:44 AM|marcoshaw|LINK
I would go with Don's suggestion. If you really want to use PowerShell to kill the process, you can, but you have to add extra code by creating what is called a runspace. There's also other solutions out there for being able to run PowerShell from ASP.NET
like "PowerShellASP" (www.powershelltoys.com).
I've not really played with these... I don't know what it might involve with impersonation.
Apr 23, 2010 09:17 AM|ph08|LINK
I like the idea of using the System.Diagnostics.Process to run the taskkill command. But I only want to do this when the last user has exited the ASP.Net application.
Do I have to track each session start and session end, to keep a count of the current users, or is there some easier and more reliable way to make sure the process only runs when the last user has ended his or her session?
Apr 23, 2010 10:19 AM|Rovastar|LINK
When the worker process ends does it then free the connection?
If so I would just reduce the Idle TimeOut from the default of 20 minutes to 1 or 2 minutes. Then 1 (or 2) minutes after the last request to that app pool it will close down and when a new request comes in it will make a new worker process for the app pool..