Capturing Traffic from .NET Services with Fiddler

If you haven’t used it previously, Fiddler is an amazing tool for tracking network activity from Windows* and invaluable when you want to watch communication between your browser and web servers.

It’s also really handy for watching communication between your web server and third parties, which is really handy if you want to intercept web service calls and see what is going on.If you’re working with ASP.NET and IIS there’s a really neat trick to route your traffic through Fiddler.

The first step is to install Fiddler on the target machine using Remote Desktop. When Fiddler launches and attaches, it adjusts the current user’s proxy settings to point at Fiddler, running on 127.0.0.1:8888 by default. That means that traffic from most applications automatically flows through Fiddler without any additional configuration steps.

However, when you want to capture web service calls from an ASP.NET page, you need to take additional steps. The easiest way to do this is to add a few lines of code to your web.config file. The nice thing about this is that if shouldn’t affect other sites running on the same server.

To do this, open web.config and add the following code at the bottom file the file within the <configuration> element, or update the system.net element if it exists .

<system.net>
    <defaultProxy enabled = "true" useDefaultCredentials = "true">
        <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
    </defaultProxy>
</system.net>

Make sure that Fiddler is running then save the file. Traffic from services should begin to flow through Fiddler:

image

When you’re done debugging, be sure to reverse the changes to web.config. If you forget to undo your changes, you’re likely to find that all of your services can no longer reach the network the moment that Fiddler is shutdown.

*If you are Mac-based check out HTTPScoop