如何使用Fiddler调试来自任何应用程序的流量(例如C#/ WPF应用程序)

Jie*_*eng 38 c# wpf webclient httpwebrequest fiddler

我想在这里调试来自另一个问题的 HTTP请求的错误.所以我读了一下Fiddler,想用它来调试我的问题.但我似乎无法通过我的WPF应用程序获得通过Fiddler的流量.我相信我需要配置一个代理.我使用WebClient作为基本示例,但我想我稍后会需要WebRequest.但是现在,通过一个简单的WebClient,我怎样才能让它通过Fiddler(我相信我必须将代理设置为localhost:8888)?

更新:

我不知道我是否做对了,但我试过了

var wc = new WebClient();
WebProxy proxy = new WebProxy();
proxy.Address = new Uri("http://localhost:8888");
wc.Proxy = proxy;
Run Code Online (Sandbox Code Playgroud)

但失败了 - 我在Fiddler看不到任何交通

我试过了 ...

var wc = new WebClient();
WebProxy proxy = new WebProxy("127.0.0.1", 8888);
wc.Proxy = proxy;
Run Code Online (Sandbox Code Playgroud)

依然没有

Jie*_*eng 53

我在这个fiddler2.com页面找到了解决方案

为什么我看不到发送的流量 http://localhosthttp://127.0.0.1?

Internet Explorer和.NET Framework是硬编码的,不通过任何代理发送对Localhost的请求,作为代理,Fiddler不会收到此类流量.

最简单的解决方法是使用您的计算机名称作为主机名而不是Localhost或127.0.0.1.所以,例如,而不是打 http://localhost:8081/mytestpage.aspx,而不是访问 http://machinename:8081/mytestpage.aspx.

  • IIS Express不会收到http:// machinename /的流量,而是路由到http://localhost.fiddler/ http://fiddler2.com/documentation/Configure-Fiddler/Troubleshooting/400ErrorFromIIS (13认同)

Lee*_*cis 16

也许有点晚了,但......

我只是通过向localhost附加一个"点"来解决这个问题,所以localhost我试图访问localhost.(注意主机名末尾的点)而不是访问

信用到期的信用:我从这个帖子得到了这个不寻常的提示http://www.west-wind.com/weblog/posts/2009/Jan/14/Monitoring-HTTP-Output-with-Fiddler-in-NET- HTTP的客户端,和WCF的代理#596591

工作良好!

  • 我认为这不再适用了.但是您可以使用http://localhost.fiddler/来使其工作. (3认同)

Tar*_*lah 12

您可以在/sf/answers/525449921/下面找到答案

它列出了您需要在web.config或App.Config中添加它

<system.net>
  <defaultProxy>
    <proxy bypassonlocal="False" usesystemdefault="True" proxyaddress="http://127.0.0.1:8888" />
  </defaultProxy>
</system.net>
Run Code Online (Sandbox Code Playgroud)
  1. 然后在运行应用程序的同一台机器上启动Fiddler.
  2. 单击工具| Fiddler Options => Connections =>将端口调整为8888.(如果需要,允许远程)
  3. 好的,然后从文件菜单中捕获流量.

这就是全部,但是在关闭fiddler之后不要忘记删除web.config行,因为如果你不这样做就会出错.

参考:http://fiddler2.com/documentation/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy