Capturing Traffic from .NET Services with Fiddler

Tuesday, January 08, 2013 by Eric Lawrence | Comments 3

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, sometimes you might want to capture traffic running in a different user account – for instance, you may want to capture web service calls from an ASP.NET page to a web service running on a different machine, or you might want to debug the traffic from a Test Studio Load Test agent, which runs under a service account.

Fortunately, if you’re an administrator, it’s pretty easy to get .NET Services to point at Fiddler. Simply open the machine.config file and add a new defaultProxy setting that points at Fiddler:

1. Start Fiddler.

2. Launch Notepad elevated (as an Administrator).

3. Open machine.config in the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config.

Note that if you are debugging a 64bit service (like ASP.NET) you will want to look in the Framework64 folder instead of the Framework folder. Similarly, if you are using a .NET version prior to 4.0, you will need to adjust the version part of the path.

4. Add the following XML block as a peer to the existing system.net element, replacing any existing defaultProxy element if present:

<!-- The following section is to force use of Fiddler for all applications, including those running in service accounts -->
<system.net>
<defaultProxy
                enabled = "true"
                useDefaultCredentials = "true">
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="
http://127.0.0.1:8888" usesystemdefault="false" />
</defaultProxy>
</system.net>

It should look like this:

image

5. Save the file.

6. Restart the services. Most services are restarted using the Services MMC applet, but for Test Studio, you can use the Start/Stop buttons in the Test Studio UI:

image

After this configuration change is made, traffic from services should begin to flow through Fiddler:

image

When you’re done debugging, be sure to revert your changes to machine.config and restart the services. 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.

 

About the author

Eric Lawrence

Eric Lawrence

(@ericlaw) has built websites and web client software since the mid-1990s. After over a decade of working on the web for Microsoft, Eric joined Telerik in October 2012 to enhance the Fiddler Web Debugger on a full-time basis. With his recent move to Austin, Texas, Eric has now lived in the American South, North, West, and East.

Posted in: hookup services howto

3  comments

  • Dave Pease 08 Jan 2013
    This is great.  I saw in the Fiddler help some stuff about doing this - but I bailed on muddling through what the help was saying.  This will be very useful to my work Thanks.
  • Bjorn 09 Jan 2013
    Thanks for the tip!
    Out of curiosity, any pros/cons altering machine.config for ASP.NET rather than configuring the proxy for WinHTTP, using httpcfg or netsh?Like:

    netsh winhttp set proxy http://127.0.0.1:8888

    Then reset when done testing using

    netsh winhttp reset proxy


  • Eric Lawrence 14 Jan 2013
    @BJorn: As far as I know, ASP.NET applications aren't using the WinHTTP proxy settings for anything. However, I must note that I haven't actually verified that the framework isn't trying to use these somewhere under the covers. Have you found that the WinHTTP settings are respected in this circumstance?

Add comment

  1. Formatting options
       
      
     
     
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)