40

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

Community
  • 1
  • 1
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
  • 1
    Just to clarify, what URL are you trying to send the HTTP request to? – EricLaw Oct 10 '10 at 02:52
  • I was trying to upload to localhost, thats my problem, then i discovered from the [fiddler docs](http://www.fiddler2.com/fiddler/help/hookup.asp#Q-DOTNET) that I won't be able to see traffic from localhost – Jiew Meng Oct 10 '10 at 10:08
  • Possible duplicate of [How can I trace the HttpClient request using fiddler or any other tool?](https://stackoverflow.com/questions/22500299/how-can-i-trace-the-httpclient-request-using-fiddler-or-any-other-tool) – Liam Aug 14 '18 at 09:30

5 Answers5

55

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.

Jeroen
  • 60,696
  • 40
  • 206
  • 339
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
  • 13
    IIS Express won't receive traffic to http://machinename/ so instead route to http://localhost.fiddler/ http://fiddler2.com/documentation/Configure-Fiddler/Troubleshooting/400ErrorFromIIS – robrich May 09 '13 at 06:02
  • 1
    It works for me.In my console application,I call a webservice that is deploy on IIS7.5 on my develop computer.And,I just replaced "localhost" with my computer name,Then Fiddler can catch the traffic. – york Jan 10 '14 at 03:16
16

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!

Zhaph - Ben Duguid
  • 26,785
  • 5
  • 80
  • 117
Lee Francis
  • 547
  • 6
  • 15
15

You can find answer in below post https://stackoverflow.com/a/7506427/471499

it lists that you need to add this in your web.config OR App.Config

<system.net>
  <defaultProxy>
    <proxy bypassonlocal="False" usesystemdefault="True" proxyaddress="http://127.0.0.1:8888" />
  </defaultProxy>
</system.net>
  1. then Start Fiddler on the same machine as the application running.
  2. Click Tools | Fiddler Options => Connections => adjust the port as 8888.(allow remote if you need that)
  3. Ok, then from file menu, capture the traffic.

That's all, but don't forget to remove the web.config lines after closing the fiddler, because if you don't it will make an error.


Run Fiddler for DotNet Core requests

RUN FIDDLER for .net core required "Netsh" tool https://learn.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh-contexts)

command to add proxy :

netsh winhttp set proxy 127.0.0.1:8880

After run the proxy, adjust Fiddler proxy to the same port, and enjoy enter image description here

remove proxy

netsh winhttp reset proxy

Reference : http://fiddler2.com/documentation/Configure-Fiddler/Tasks/UseFiddlerAsReverseProxy https://docs.telerik.com/fiddler/configure-fiddler/tasks/configuredotnetapp

Tarek El-Mallah
  • 4,015
  • 1
  • 31
  • 46
4

All the time I use below configuration to redirect the network HTTP calls to pass thru fiddler proxy from my applications.

This works in all kinds of .NET applications (which has either web.config or app.config file) and in fiddler its best to disable Capture Traffic option to avoid capturing general traffic from all the applications running. Shortcut key for this is F12.

<system.net>
    <defaultProxy>
        <proxy proxyaddress="http://localhost:8888/" />
    </defaultProxy>
</system.net>

This is valuable configuration if you have third party assemblies in which you don't have chance of changing the code that calls URL.

I hope this helps someone.

Harsh Baid
  • 7,199
  • 5
  • 48
  • 92
  • For some reason this wont work in my WPF application. I have to manually force it to use the proxy. – rollsch Aug 21 '17 at 04:56
1

"IIS Express won't receive traffic to machinename so instead route to localhost.fiddler fiddler2.com/documentation/Configure-Fiddler/Troubleshooting/… – robrich May 9 '13 at 6:02"

RobRich above got it right. This is the only thing that worked as I can only use IIS Express.

RandallTo
  • 395
  • 2
  • 11