98

I have IIS 5.1 on a XP machine, and visual studio 2005. How do I go about attaching my debugger to IIS instance.

BTW: I'm not seeing the IIS process within the running processes or probably I don't know what to look for .

Mihai Lazar
  • 2,249
  • 2
  • 19
  • 27
  • 1
    For others coming from Google: Apparently this is not doable in Visual Web Developer 2010 Express. I'm suspecting that it's not there in Visual C# Express either. – Joel Peltonen Jul 15 '13 at 12:55
  • 1
    Possible duplicate of [How do I attach the debugger to IIS instead of ASP.NET Development Server?](http://stackoverflow.com/questions/210250/how-do-i-attach-the-debugger-to-iis-instead-of-asp-net-development-server) – Aaroninus Nov 03 '15 at 13:04

8 Answers8

165

In Visual Studio:

  1. Click "Debug" from the menu bar
  2. Click "Attach to Process"
  3. Check the "Show processes from all users" checkbox in the bottom left corner
  4. Select aspnet_wp.exe, w3p.exe, or w3wp.exe from the process list
  5. Click "Attach"
Iman
  • 17,932
  • 6
  • 80
  • 90
Al W
  • 7,539
  • 1
  • 19
  • 40
  • 1
    Thanks, by any chance do you know how to do this in Vista Business and IIS 7 ? – Mihai Lazar May 12 '09 at 08:46
  • 35
    try to look for w3p.exe process and attached it using the steps above – jerjer Apr 16 '10 at 09:23
  • 2
    @Mihai: On Vista/Win7/2008/2008R2 you'll also need to run the debugger as an administrator to be able to do this. – Richard Dec 21 '10 at 09:46
  • 1
    @Rcihard One other thing is when there are multiple ApplicationDomains each starts another w3wp.exe instance and I need to be on the look out for which is the one currently running my code :) – Mihai Lazar Jan 25 '11 at 08:26
  • 6
    @MihaiLazar Run `C:\windows\system32\inetsrv\appcmd list wp` to list the application pools and their process IDs and find which one to attach to. http://blogs.msdn.com/b/friis/archive/2009/10/22/which-w3wp-exe-pid-corresponds-to-which-application-pool.aspx – Nathan Oct 16 '14 at 22:32
  • I use this to debug regularly, but often the w3p.exe won't show up for me. What could cause that? – MrFox Jun 09 '15 at 11:38
  • 1
    If you don't see w3p.exe. may be you don't run your website. try run it on browser – Wolf Oct 15 '15 at 09:16
  • and what else? it's still undebuggable – Hassan Faghihi Jan 09 '16 at 09:31
  • 1
    The UI route gets tedious, so I find this useful: [Keystrokes to attach to w3wp.exe](http://stackoverflow.com/a/27006842/1495860). – mungflesh Dec 15 '16 at 15:05
19

Just to clarify Jimmie R. Houts answer…

If you want to debug the web application VS and IIS you can do the following:

  1. Host the site inside IIS (virtual directory etc).
  2. Then in VS2005 do this:

    • Right Click on Web Project → Properties → Start options → Use Custom Server → Base URL → Enter Site Address as Hosted in IIS.
    • Hit F5 and you will be able to Debug your code

Same works for VS 2008 also.

Vadim Ovchinnikov
  • 13,327
  • 5
  • 62
  • 90
Amitd
  • 4,769
  • 8
  • 56
  • 82
  • Years on, I can confirm this still works on newer IIS versions (currently using 10.0.18362.1 via Windows 10). Did the above steps in VS2010 and was able to remotely debug without attaching to services. Unable to find w2p.exe, w3wp.exe, aspnet_wp.exe, donet.exe, or inetinfo.exe for attaching besides. – Feynt Nov 17 '20 at 20:43
15

I'm running Windows 7 with IIS Version 7.5 and I also needed to tick the "Show processes from all users" and "Show processes in all sessions" boxes - at the bottom of the "Attach to Process" dialog.

Also I had put my app in a specific App Pool which means you can then see it labeled against the w3wp.exe.

The Coder
  • 4,981
  • 2
  • 29
  • 36
6

The possible names of the ASP.NET process:

  • w3wp.exe is IIS 6.0 and later.
  • aspnet_wp.exe is earlier versions of IIS.
  • iisexpress.exe is IISExpress.
  • dotnet.exe is ASP.NET Core.
  • inetinfo.exe is older ASP applications running in-process.

From Find the name of the ASP.NET process

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
5

The IIS process is aspnet_wp.exe.

In fact, attaching to the aspnet_wp.exe process is what VS does when you have your project set to use IIS for debugging.

Jimmie R. Houts
  • 7,728
  • 2
  • 31
  • 38
1

Using an Attach to IIS plugin (VS2015, VS2017) plugin saves a few clicks - especially when dealing with an ecosystem of IIS hosted sites (one frontend with multiple backend services say)

fiat
  • 15,501
  • 9
  • 81
  • 103
1

You'll also need to open Internet Information Service From Control Panel > Administrative Tools. Right click the web site in question, click the home directory tab, and select the configuration button. This will open a new form with three tabs - click the debugging one and select the two options in the debugging flag section. This is also necessary to debug.

Taryn
  • 242,637
  • 56
  • 362
  • 405
Mike
  • 5,181
  • 3
  • 25
  • 19
  • 2
    This is only needed to debug ASP code. ASP.NET, ISAPI, ... and all other means of adding code do *not* require this. – Richard Dec 21 '10 at 09:47
0

If you see the process [e.g. IIS Worker Process (w3wp.exe)] running is Task Manager, but not in the list of processes in debug > attach to process, you might need to run Visual Studio as administrator.

Haukland
  • 677
  • 8
  • 25