Stop the w3wp process? [Answered]RSS

4 replies

Last post Apr 23, 2010 10:19 AM by Rovastar

  • Stop the w3wp process?

    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?

  • Re: Stop the w3wp process?

    Apr 22, 2010 10:53 PM|don.raman|LINK

    Hi,

    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 http://forums.asp.net/t/1494083.aspx. Or here.

    Thanks,

    Don.

  • Re: Stop the w3wp process?

    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.

  • Re: Stop the w3wp process?

    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?

  • Rovastar Rovastar

    5473 Posts

    MVP

    Moderator

    Re: Stop the w3wp process?

    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..

    Troubleshoot IIS in style
    https://www.leansentry.com/