Monday, October 27, 2008

Listing process IDs for IIS application pools

When working with ASP.NET applications on a server that runs several ASP.NET applications, You once in a while end up troubleshooting which of the applications that are using up all the CPU or memory.

The problem is that in Windows Task Manager, You only see a bunch of w3wp.exe processes. You cannot see which application pool each process is.

To our help, we find the iisapp.vbs script that lists all applications pools and their process ids. A simple bat file that You can put on You desktop contains he following commands:

cd \WINDOWS\system32
cscript iisapp.vbs
pause

Since You can see the process id in Windows Task Manager, we can now identify which application to blame (since You run each application in it’s own application pool, don’t You?).

Wrong URL:s in WSDL for Web Service implemented with WCF

If You expose a WCF web service in the following way:

  • The external name (on the public Internet) is webserver1.mycompany.com
  • The internal machine name (in my company’s internal network) is www_1.mycompany.local
  • The service path on the server is  /MyService/MyService.svc
  • The web site that the service resides in does not have any host headers defined.

If You browse (using a web browser) to the URL

http://webserver1.mycompany.com/MyService/MyService.svc,

You will see that the suggested URL to the WSDL is

http://www_1.mycompany.local/MyService/MyService.svc?wsdl .

If You ignore the incorrect URL and browse to

http://webserver1.mycompany.com/MyService/MyService.svc?wsdl (the correct URL for the WSDL), You will see that also the WSDL says that the web service is located at http://www_1.mycompany.local/MyService/MyService.svc.

The problem is that WCF does not realize that the URL of the web service is the external address.

The solution is pretty simple: set correct host header for the web site:

webserver1.mycompany.com for port 80 (and port 443 if You are about to expose the web service using SSL, which You should).

Restart the application pool and reload the service page in Your browser and everything should be fine.