I used to do this:
How to attach to the correct process in IIS6
IIS6 uses seperate process for each AppPool, usefully these all have the same name - w3wp.exe.
To determine which AppPool? the application is using right click>properties on the directory in InetMgr? and look at the AppPool list at the bottom.
To determine which process matches which AppPool type the following at the command prompt:
You may get a message box asking if you want to change your default VBScript provider to CScript. If for some reason you don't, type:
This will list the process ids for each app pool, then all you have to do is match the process id in visual studio's attach to process screen.
W3WP.exe PID: 5124 AppPoolId: SharePoint - 80 W3WP.exe PID: 4236
AppPoolId: DefaultAppPool W3WP.exe PID: 728 AppPoolId: SharePoint Central Administration v3 W3WP.exe PID: 4128 AppPoolId: ReportServer
But this doesnt seem to work on Server 2008. Is there a better method?