Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

Fiddler and Application Proxy setup


:P
On this page:

I’ve been working on a couple of apps that do extensive HTTP and Web Service access over the last few days and Fiddler has been a huge help in debugging some odd problems I’ve been having. This ASP.NET Web app has both .NET and FoxPro clients talking to it and checking out the traffic and difference of the client communication was driving me nuts for a while.

 

One tool I continue to use all the time when working on any sort of distributed application is Fiddler. If you haven’t used Fiddler before, run, don’t walk and download this awesome little proxy that lets you easily see the content of requests made over HTTP over the network. It works great, but keep in mind it doesn’t work for Localhost (it might with a loopback adapter though – haven’t tried it) or over HTTPS in which case you have to remember to step it down to HTTP for debugging. It’s great for debugging problems in distributed applications, but is also great if you need to debug Web based applications for things like Cookies, custom headers etc. What makes Fiddler nice is that shows both content and headers and lets you easily view all of this diverse content in a somewhat intuitive way – for example, images can be previewed, XML can be viewed as a node list and you can apply viewers to any content sent or returned. If you’re building any kind of Web application sooner or later this functionality will come in REAL handy.

 

Fiddler works by setting up a proxy on port 8888 and then re-routing Web requests through it. It does this by basically changing IE’s proxy settings on the fly.

 

If you’re using a .NET client though you will have to configure the client in order for Fiddler to be able to see the communication. By default the .NET HttpWebRequest uses direct connections – meaning it doesn’t check or use for any proxies in the system and will thus not be picked up by Fiddler once it’s started.

 

If you’re using .NET you have to tell the .NET HTTP clients to use a proxy object. .NET allows you to custom configure a proxy using the Proxy property. The Proxy object is available both on lower level objects like HttpWebRequest as well as on higher level objects like a Web Services proxy.

 

You can configure a Proxy object manually by creating a new WebProxy object:

 

WebRequest.Proxy = new WebProxy("127.0.0.1:8888",true);

 

or probably the better choice: You can use the default proxy which reads the Internet Explorer settings for the current user:

 

WebRequest.Proxy = WebProxy.GetDefaultProxy();

 

You can apply the same logic to a Web Service client’s Proxy property as well.

 

If you’re using the MSSOAP Toolkit, you also have to do some custom configuration. You also need to set the Proxy server using the appropriate ConnectorProperty:

 

THISFORM.oNet = CREATEOBJECT("MSSOAP.SoapClient30")

THISFORM.oNet.MSSOAPInit(lcWSDLURL)

thisform.oNet.ConnectorProperty("ProxyServer")="<CURRENT_USER>"

loNL = thisform.oNet.LoadAuthors("");

 

If you’re using WinInet you can use a Connection type in Interopen:

 

hInetConnection=;

   InternetOpen(THIS.cUserAgent,;

   THIS.nhttpconnecttype,;

   THIS.chttpproxyname,THIS.chttpproxybypass,0)

 

Where the ConnectType is 0 for IE Configuration, 3 for custom proxy, and 1 for direct access. Generally you’ll want to use 0. If you’re using wwHTTP in Visual FoxPro, nHttpConnectType is defaulted to 0 which maps to this WinInet setting.

 


The Voices of Reason


 

Scott Allen
October 11, 2004

# re: Fiddler and Application Proxy setup

I've found the GlobalProxySelection class to be useful to, i.e:

GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);

Thanks for the tips, these are useful!

Kevin Wright
October 14, 2004

# re: Fiddler and Application Proxy setup

I can certainly second your comments as to how useful Fiddler is. It certainly helped me out recently when trying to access a complex .NET web service call from a third party using VFP.

Unfortunately I didn't get the chance to try your new wwSoap - I ended up hand coding the XML creation instead.

Kevin

Ben Empson
March 16, 2005

# re: Fiddler and Application Proxy setup

Hi there, I'm trying to use fiddler for local debugging of a webservice too. Difference is my soap server is written in PHP5 running on Apache on port 81. I simply cannot get my .Net application to run through fiddler for this setup?! I don't get it, as if I access the webservice through IE, fiddler picks up on everything quite happily, so it can't be the port. Don't suppose you have any ideas do you?!

AHA, Ben

Rick Strahl
March 16, 2005

# re: Fiddler and Application Proxy setup

I think Fiddler only re-routes port 80. You might shut down IIS (I presume that's why you're using Apache on 81) and restart Apache on 80 and see if that works.

Also, make sure that if you're using a .NET Web Service client that you set:

YourService.Proxy = WebProxy.GetDefaultProxy();

This will make sure that .NET uses IE proxy settings if any. Since Fiddler basically hooks IE's settings and writes them into IE this works.

Ben Empson
March 16, 2005

# re: Fiddler and Application Proxy setup

Hi Rick :)

I have tried shifting Apache onto port 80 but no luck. It's also confusing as if I access the service via IE on port 81 Fiddler picks up the request.

I have tried setting the .Net client proxy as suggested but no luck also :(

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2025