Debugging HTTP

Tuesday, June 29, 2004

In debugging some web service wierdness I downloaded Fiddler. Fiddler is an excellent tool for viewing and experimenting with the HTTP headers and payload exchanged between client and server. I've never used a debugging proxy that is so easy and informative.

Any software using the WinINET API (like IE) will automatically send traffic through fiddler when the “Act as System Proxy” check box is checked.

For the .NET classes like HttpWebRequest and WebClient, I found the GlobalProxySelection class is pretty useful for setting the proxy programatically:

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

Before yesterday I didn't know this class existed. It's amazing what I can find when I venture outside of my “framework comfort zone”.


Comments
Eric Lawrence Tuesday, June 29, 2004
Thanks for the mention, and the tip on the GlobalProxySelection class!
<br>
Ben Empson Wednesday, March 16, 2005
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?!
<br>
<br>AHA, Ben
Scott Saturday, March 19, 2005
I'm not sure, Ben. The GlobalProxySelection class has always worked for me....
EricLaw [MSFT] Wednesday, May 3, 2006
The .NET Framework automatically bypasses http://127.0.0.1; you need to use IE to hit http://machinename for the framework to use the proxy.
Rick Strahl Sunday, May 7, 2006
Scott, depending on your proxy settings in your .config file, .NET will automatically pick up any proxy changes made in IE including Fiddler. The default in .NET 2.0 is to use the System Proxy settings and so you should automatically see Web Service or WebRequest requests show up in fiddler even against localhost (since Fiddler clears the bypass list).

To be sure though use the machine name as Eric recommends - the NetBios name should always work.

Note this can be turned off in Web.Config and in fact in Web applications, especially local ones you probably want to turn the auto-proxy off.

http://west-wind.com/weblog/posts/3871.aspx
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!