In SharePoint, if you want to debug your code then you need to attached W3WP worker process in Visual Studio to start debugging. Generally, we are attaching all the worker process. By doing this all the SharePoint services goes in the debugging mode and your process takes more execution time then it generally takes. To avoid this we have to attached only worker process (W3WP) which is associated with our application.
To attach worker process we need to navigate Tools Menus > Attach Process or we can use short cut command i.e. Ctrl + P. It will open new window in which all the process are listed and we will find the w3wp process and attach all that process to start the debugging.
To find which w3wp worker process is associated with our application, we need to go to IIS Manager which is very long process and other one is using Command Prompt.
Find associate process using IIS Manager
1. Open IIS Manager
2. Click on Worker Processes as displayed in below image.
3. It will display your application name as well as Process ID. By the use of Process ID you can attach only 1 process to debug your code.
In above process after every deployment you need to close the current Worker Process window and again open it to get it refresh so that it’s time consuming and hectic process.
Find associate process using Command Prompt
1. Open command prompt with Run as Administrator
2. Navigate to C:\Windows\System32\Inetsrv
3. C:\Windows\System32\Inetsrv> appcmd list wp to get all worker process along with Application Pool name. You will get result as below image.
This is very simpler method to get Process ID of your application while developing SharePoint custom code.
Enjoy 🙂 Happy Coading..:)