15

I built a Web API service that's hosted locally on my machine in IIS. I have an iOS app that I'm running via XCode that makes the call to the web service. The connectivity is there, and works. The iOS app successfully makes the connection to my published web service.

The problem is my web service is returning a non descriptive error to the client (iOS), so what I need to be able to do is step through the web service code while running my iOS app.

So, in summary:

  1. I run an iOS app via my MacBook, and it connects to my .NET Web API service.
  2. My Web API service is published to my local IIS, and is returning an error back to the client.
  3. Breakpoints aren't being hit in Visual Studio - do I need to attach my Visual Studio debugger to a specific process? I've tried running my web service in debug mode while running my iOS app, to no avail.

How can I step through my web service code when running the client app (iOS) that accesses the web service?

Mike Marks
  • 10,017
  • 17
  • 69
  • 128

5 Answers5

23

Attach to process - http://msdn.microsoft.com/en-us/library/vstudio/3s68z0b3.aspx

Make sure "Show processes from all users" is checked, and pick w3wp.exe

You may need to hit the service once first to make sure its started.

EkoostikMartin
  • 6,831
  • 2
  • 33
  • 62
  • That's what I thought too, and works often, but it's not working in this case... When I attach w3wp.exe, my breakpoint turns to the yellow point (symbols have not been loaded yet), which is fine, because I'm used to it turning red once it's about to be hit. It never does. I start up my iOS app while my web service is attached to w3wp.exe, and my breakpoint never gets hit, even though I know it's hitting my web service. – Mike Marks May 02 '13 at 19:53
  • 1
    Make sure your service is compiled in debug mode before being deployed to local IIS. – EkoostikMartin May 02 '13 at 19:56
  • Try this, delete your local bin folder completely, rebuild (in debug mode) and redeploy to IIS. – EkoostikMartin May 02 '13 at 20:06
  • 2
    Also make sure to move the .pdb files as well. Those are used for debugging. – ZanderAdam May 02 '13 at 20:17
  • Does it matter if I publish my web service to a physically different location than my workspace? – Mike Marks May 02 '13 at 20:21
  • THe other guy posted their answer first, but you were more helpful, therefore got the answered status... – Mike Marks May 02 '13 at 20:50
  • 2
    @MikeMarks Can you post your answer? – digitguy Aug 24 '16 at 19:51
  • Ahhh the classic "I figured it out, thanks" and doesn't share how. – ScottN Nov 07 '19 at 15:32
  • 1
    FYI, for others coming across this, you need to goto the ApplicationPool and change the "Process Model > Idendity" to start as an Admin user that you use when you're attaching to the process from Visual Studio. – ScottN Nov 07 '19 at 15:37
11

To debug an app that's hosted by IIS, you want to attach to process (in Visual Studio it's Tools->Attach to Process or Ctrl+Alt+P) and pick w3wp.exe from the list (you might have to check a few boxes for the process to show up).

Stephen Fischer
  • 2,445
  • 2
  • 23
  • 38
  • That's what I thought too, and works often, but it's not working in this case... When I attach w3wp.exe, my breakpoint turns to the yellow point (symbols have not been loaded yet), which is fine, because I'm used to it turning red once it's about to be hit. It never does. I start up my iOS app while my web service is attached to w3wp.exe, and my breakpoint never gets hit, even though I know it's hitting my web service. – Mike Marks May 02 '13 at 19:54
  • I had to run VS as administrator too. – Maria Ines Parnisari Jan 18 '16 at 14:31
1

Another option is to use our free VS Extension called Conveyor https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti With it you open up IIS Express to remote connections on your network (or even the web through tunnelling). Once you've done that you can debug the project directly from VS and connect to the Conveyor port number (or domain name via tunnelling) and debug as you would locally.

Jim W
  • 4,866
  • 1
  • 27
  • 43
0

you can use Postman client.

First : run the API FROM visual studio Second : go to postman put the url and add the parameter in body

More information : http://www.tutorialsteacher.com/webapi/test-web-api

0

this often works for me i generally list all of the processes in IIS with appcmd command

appcmd list wp

and pretty much you know which process to attach by seeing the names of the web services

if appcmd is not available please visit

Here for configuring this

ansar
  • 128
  • 13