通过本地主机连接到远程

Connecting to remote goes through localhost

我有一个来自我的 C# 控制台应用程序的 http 调用。 url 在 HttpClient 中指定。但是,我希望它不使用 localhost 作为代理,而是直接连接到我指定的 url。我打算在它工作时将其移动到 Web 表单应用程序。

我目前可以在 Fiddler 中看到调用,因此必须在某处进行配置。

有办法吗?

我想尝试这个的原因是因为当我 运行 一个 curl 调用

curl -x localhost:8888 -XPOST -d 'Metadata="123"' http://uri.uri [Visible in Fiddler. Doesn't return values.]
curl -XPOST -d 'Metadata="123"' http://uri.uri [Invisible in Fiddler. Returns values]

我的c#http请求和curl调用是一样的。我可以在 Fiddler 中看到它,这意味着它使用 localhost 作为代理,但我没有收到任何值。

HttpClient 使用 Windows“Internet 选项”中的默认代理配置。因此,如果您在 Fiddler 中看到来自您的应用程序的流量,则意味着默认代理配置指向 Fiddler。

这并不奇怪,因为 "Act as System Proxy on startup" is an option in Fiddler:它会在 Fiddler 启动时将 Windows 默认代理更改为自身,并在 Fiddler 关闭时将其更改回来。

要在 Fiddler 中验证该选项,请打开 Fiddler 的选项,转到“连接”选项卡,然后查看是否选择了 "Act as System Proxy on startup"。