Need to debug my Web API service that's requested from a client machine - need help, how do I do this?
Asked Answered
K

6

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?

Kyrstin answered 2/5, 2013 at 19:41 Comment(0)
M
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.

Mcburney answered 2/5, 2013 at 19:45 Comment(9)
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.Kyrstin
Make sure your service is compiled in debug mode before being deployed to local IIS.Mcburney
Try this, delete your local bin folder completely, rebuild (in debug mode) and redeploy to IIS.Mcburney
Also make sure to move the .pdb files as well. Those are used for debugging.Cecilacecile
Does it matter if I publish my web service to a physically different location than my workspace?Kyrstin
THe other guy posted their answer first, but you were more helpful, therefore got the answered status...Kyrstin
@MikeMarks Can you post your answer?Ibbetson
Ahhh the classic "I figured it out, thanks" and doesn't share how.Ancillary
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.Ancillary
S
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).

Subreption answered 2/5, 2013 at 19:45 Comment(2)
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.Kyrstin
I had to run VS as administrator too.Bubal
S
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.

Stevana answered 12/3, 2018 at 16:54 Comment(0)
M
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

Moshe answered 27/12, 2018 at 15:27 Comment(0)
M
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

Mizzenmast answered 31/12, 2019 at 4:39 Comment(0)
S
0

For anyone running into this in the future, I was going CRAZY trying to figure out how to troubleshoot this. Since the error 500 isn't in code, no detailed logs were being saved (even with the additional logging turned on).

I then realized that if I had a real site with a configuration issue I could browse to it on the server and I would get detailed information.

So I installed postman on the server itself and ran the test against the API when then provided detailed information on what it was getting stuck on! Running postman on my dev box against the API just provided an error occurred.

Skipbomb answered 16/5, 2024 at 15:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.