App 绝对拒绝对 localhost 请求使用代理

App absolutely refuses to use proxy for localhost requests

我在端口 8888 上安装了 Fiddler 运行

Web.config:

  <system.net>
      <defaultProxy enabled="true" useDefaultCredentials="true">
          <proxy bypassonlocal="False" proxyaddress="http://localhost:8888" usesystemdefault="False" autoDetect="False" />
      </defaultProxy>
  </system.net>

应用程序代码(指定与之通信的 API 控制器的凭据):

            var wc = new WebClient();
            wc.Proxy = new WebProxy(new Uri($"http://localhost:8888"), false);
            wc.Credentials = new NetworkCredential("myuser", "mypass");
            var response = wc.UploadString("http://localhost:11026/api/mycontroller/mymethod", "POST", request);

我一辈子都无法让它通过 Fiddler 进行通信,因此我可以调试请求。我做错了什么吗?

更新
此信息由 Fiddler help 提供,但在 web.config 和应用程序代码中都使用了 localhost.fiddler,但仍未被 Fiddler 捕获(当 Fiddler 关闭时,它不会导致连接失败错误)

Solution 2: Use http://ipv4.fiddler

Use http://ipv4.fiddler to hit localhost on the IPv4 adapter. This works especially well with the Visual Studio test webserver (codename: Cassini) because the test server only listens on the IPv4 loopback adapter. Use http://ipv6.fiddler to hit localhost on the IPv6 adapter, or use http://localhost.fiddler to hit localhost using "localhost" in the Host header. This last option should work best with IIS Express.

与其尝试通过代理发送,不如通过 fiddler 环回之一发送。

比如http://fiddler.ipv4:11026……

详情在这里:

http://docs.telerik.com/fiddler/observe-traffic/troubleshooting/notraffictolocalhost

展示如何设置它和捕获流量。当我想查看本地 web api 和我的 Mvc 项目之间传递的流量时,我就使用了这种方法