简体   繁体   中英

Getting IIS workerprocess from ApplicationHost.config

I need to get IIS worker processes without using appcmd or ServerManager. If I use PerformanceCounter I can get only process Id not App pool name. I have checked the code behind ServerManager and it seems it's loading form applicationHost.Config but I couldn't find WorkerProcess section in that. I can get list of Application pools from applicationhost but I need processId as well. Is there any windows API to get app pool and process ID together?

Get work process information and get application pool configuration will rely on differnt things. As lex said, IIS will not store active worker process information in applicationhost.config.

If you want to read some application pool configuration, it is recommended to use Microsoft.Web.administration .

If you need to get both application pool and PID, then use commandline " APPCMD LIST WPS " in administrator would be the easiest way even you are not willing to use both Appcmd and server manager.

If Appcmd and server manager is not acceptable at all, you could use Process.GetProcessesByName() to get worker Process collection. Then get their application pool by getting the their username with WMI . Since the username of a worker process would be IIS Apppool\ Apppool name .

Since user may change application pool will be changed to local managed account. It is not recommended to accept this workaround.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM