Sunday, September 25, 2011

Which w3wp.exe process belongs to which App Pool

When you are debugging a ASP.NET web application which is hosted on IIS, you need to attach the particular worker process in Visual Studio to start debugging. The process to attach a process J is go to Tools > Attach Process or use shortcut key Ctrl+Alt +P. The process window will show the worker process (w3wp.exe) which is currently running on IIS. You need to select the process and click on attach button to start the debugging. Problem starts when you have multiple worker process running on IIS. If you have multiple sites hosted on IIS and each site having their own application pool then you will see the list of all worker process in the Process Attach window.

Whenever we create a new Application Pool, the ID of the Application Pool is being generated and it’s registered with the HTTP.SYS (Kernel Level of IIS). Thus, whenever HTTP.SYS  receives any request from any web application, it checks for the Application Pool and based on the application pool ID, it send the request to appropriate worker process

I will straight way show you how to do the same on command prompt for IIS 6 & 7:

 IIS 6:

1.       Go to command prompt (run->cmd)

2.       Go to system32, the prompt should be like -

Write C:\>cd WINDOWS\system32 and you will reach C:\WINDOWS\system32>

Since the cscript.exe  resides here.

3.       Next command is – cscript iisapp.vbs

IIS 7:

From IIS 7.0 you need you to run IIS Command Tool ( appcmd ) .
1.  Start > Run > Cmd
2. Go To Windows > System32 > Inetsrv
3. Run appcmd list wp

This will show you list worker process that is running on IIS 7.0 in the similar format of IIS 6.0

And you get all the w3wp.exe with process id with AppPool id.

C:\WINDOWS\system32>cscript iisapp.vbs

Microsoft (R) Windows Script Host Version 5.6

Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

 

W3WP.exe PID: 8104   AppPoolId: SharePoint - 7011

W3WP.exe PID: 8080   AppPoolId: SharePoint Central Administration v3

W3WP.exe PID: 7600   AppPoolId: SharePoint - 7010

W3WP.exe PID: 148   AppPoolId: MyWebApp

Now you have the liberty to attach the desired process only. J

Thanks for reading. If you have some other explanation – please post a comment… I’ll be happy to hear.

...HaPpY CoDiNg

Partha (Aurum)

References:

No comments:

Post a Comment