Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Fiddler to debug traffic from Any app (eg. C#/WPF app)

I am tring to debug whats wrong with my HTTP requests from another question here on SO. So i read a bit about Fiddler and wanted to use it to debug my problem. But I can't seem to get traffic from my WPF application to go through Fiddler. I believe I need to configure a proxy. I am using a WebClient for a basic example, but I think i will require a WebRequest later. But for now, with a simple WebClient, how can I get it to go through Fiddler (I believe I have to set proxy to localhost:8888)?

UPDATE:

I don't know if i did the right thing or not but I tried

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

but failed - I don't see any traffic in Fiddler

I tried ...

var wc = new WebClient(); WebProxy proxy = new WebProxy("127.0.0.1", 8888); wc.Proxy = proxy; 

still nothing

like image 851
Jiew Meng Avatar asked Oct 09 '10 08:10

Jiew Meng


People also ask

Can Fiddler capture traffic from application?

Fiddler is a free web debugging proxy that logs all HTTP/HTTPS traffic between your web application and the Internet.

How do you use Fiddler everywhere to capture traffic?

Click Open Browser from the Live Traffic toolbar. Enter the URL in the newly opened Chrome window. Fiddler Everywhere immediately starts capturing all the traffic generated from the preconfigured browser.

Can you hack with Fiddler?

For security folks, Fiddler can be used to conduct web penetration testing: you can use it to decrypt web traffic and manipulate sessions and requests.


2 Answers

I found the solution at this fiddler2.com page

Why don't I see traffic sent to http://localhost or http://127.0.0.1?

Internet Explorer and the .NET Framework are hardcoded not to send requests for Localhost through any proxies, and as a proxy, Fiddler will not receive such traffic.

The simplest workaround is to use your machine name as the hostname instead of Localhost or 127.0.0.1. So, for instance, rather than hitting http://localhost:8081/mytestpage.aspx, instead visit http://machinename:8081/mytestpage.aspx.

like image 50
Jiew Meng Avatar answered Sep 30 '22 11:09

Jiew Meng


Maybe a little late, but...

I get around this simply by appending a "dot" to localhost, so instead of accessing localhost, I try to access localhost. (notice the dot at the end of the hostname)

Credit where credit is due: I got this unusual tip from this thread http://www.west-wind.com/weblog/posts/2009/Jan/14/Monitoring-HTTP-Output-with-Fiddler-in-NET-HTTP-Clients-and-WCF-Proxies#596591

Works fine!

like image 40
Lee Francis Avatar answered Sep 30 '22 11:09

Lee Francis