C# 需要调试从客户端计算机请求的 Web API 服务 - 需要帮助,我该怎么做?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16346395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 00:49:01  来源:igfitidea点击:

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

c#.netxcodevisual-studio-debuggingasp.net-web-api

提问by Mike Marks

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.

我构建了一个 Web API 服务,该服务在 IIS 中本地托管在我的机器上。我有一个通过 XCode 运行的 iOS 应用程序,它调用 Web 服务。连接在那里,并且有效。iOS 应用程序成功连接到我发布的 Web 服务。

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.

问题是我的 Web 服务向客户端 (iOS) 返回了一个非描述性错误,因此我需要能够在运行我的 iOS 应用程序时逐步执行 Web 服务代码。

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.
  1. 我通过我的 MacBook 运行一个 iOS 应用程序,它连接到我的 .NET Web API 服务。
  2. 我的 Web API 服务已发布到我的本地 IIS,并向客户端返回错误。
  3. 在 Visual Studio 中未命中断点 - 我是否需要将我的 Visual Studio 调试器附加到特定进程?我尝试在运行我的 iOS 应用程序时以调试模式运行我的 Web 服务,但无济于事。

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

在运行访问 Web 服务的客户端应用程序 (iOS) 时,如何单步执行我的 Web 服务代码?

采纳答案by EkoostikMartin

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

附加到进程 - http://msdn.microsoft.com/en-us/library/vstudio/3s68z0b3.aspx

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

确保选中“显示所有用户的进程”,然后选择 w3wp.exe

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

您可能需要先点击该服务以确保其已启动。

回答by Stephen Fischer

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.exefrom the list (you might have to check a few boxes for the process to show up).

要调试由 IIS 托管的应用程序,您需要附加到进程(在 Visual Studio 中,它是工具->附加到进程或 Ctrl+Alt+P)并w3wp.exe从列表中选择(您可能需要为进程选中几个框现身)。

回答by Jim W says reinstate Monica

Another option is to use our free VS Extension called Conveyor https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyotiWith 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.

另一种选择是使用我们的免费 VS 扩展名为 Conveyor https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti使用它您可以打开 IIS Express 到您的网络(甚至网络)上的远程连接通过隧道)。完成后,您可以直接从 VS 调试项目并连接到 Conveyor 端口号(或通过隧道连接的域名)并像在本地一样进行调试。

回答by Juan Carlos Roa

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

第一:从 Visual Studio 运行 API 第二:去邮递员那里输入 url 并在正文中添加参数

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

更多信息:http: //www.tutorialsteacher.com/webapi/test-web-api

回答by ansar

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

这通常对我有用我通常使用 appcmd 命令列出 IIS 中的所有进程

appcmd list wp

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

通过查看 Web 服务的名称,您几乎知道要附加哪个进程

if appcmd is not available please visit

如果 appcmd 不可用,请访问

Herefor configuring this

这里用于配置这个