简体   繁体   English

连接到远程通过本地主机

[英]Connecting to remote goes through localhost

I've a http call from my c# console application. 我从c#控制台应用程序发出了http呼叫。 The url is specified inside HttpClient. 网址是在HttpClient内部指定的。 However, I'd like it to not use localhost as a proxy and instead directly connect to the url I've specified. 但是,我希望它不使用localhost作为代理,而是直接连接到我指定的URL。 I intend to move this to a web forms application when it works. 我打算在工作时将其移至Web窗体应用程序。

I can currently see the calls in Fiddler so that must be configured somewhere. 我目前可以在Fiddler中看到调用,因此必须在某个地方进行配置。

Is there a way to do this? 有没有办法做到这一点?

The reason why I want to try this is because when I run a curl call 我想尝试此操作的原因是因为当我运行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]

My c# http request is the same as the curl call. 我的c#http请求与curl调用相同。 I can see it in Fiddler, meaning it's using localhost as proxy, and I'm not receiving any values. 我可以在Fiddler中看到它,这意味着它正在使用localhost作为代理,并且没有收到任何值。

HttpClient uses the default proxy configuration from Windows' Internet Options. HttpClient使用Windows“ Internet选项”中的默认代理配置。 So if you see the traffic from your app in Fiddler, then that means the default proxy config is pointing to Fiddler. 因此,如果您在Fiddler中看到来自应用程序的流量,则意味着默认代理配置指向Fiddler。

That is not surprising since "Act as System Proxy on startup" is an option in Fiddler : it will change the Windows default proxy to itself when Fiddler starts up and change it back when Fiddler closes. 这并不奇怪,因为“在启动时充当系统代理”是Fiddler中的一个选项 :它将在Fiddler启动时将Windows默认代理更改为自身,而在Fiddler关闭时将其更改为默认代理。

To verify that option in Fiddler, open Fiddler's options, go to the Connections tab, and see if "Act as System Proxy on startup" is selected. 要验证Fiddler中的选项,请打开Fiddler的选项,转到“连接”选项卡,然后查看是否选择了“启动时充当系统代理”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM