For debugging network traffic we often use the web debugging tool Telerik Fiddler. When it comes to debugging web applications in development environments that do REST calls to localhost in the background, these calls will not get tracked by Fiddler. In my case I had a LightSwitch application that uses two service references as data sources. On my development VM the service reference URL points to the same machine (i.e. http://localhost:53224/api/Core), so these let’s say “inner” requests didn’t get recorded by Fiddler.

To enable recording these requests there are several possibilities offered by Fiddler. In the next section I show you how I solved this problem.

Solution

Instead of doing calls directly to localhost the calls will be redirected to localhost by Fiddler itself and then they get recorded automatically.

  1. Replace http://localhost:123/ in your URI/URL with an arbitrary host name (i.e. http://appclusive/).
  2. Start Fiddler
  3. In the top menu select Rules -> Customize rules...
    fiddler-1
  4. In the file that gets opened go to the function OnBeforeRequest(oSession: Session)
  5. Add a new request modification entry as described here
    if (oSession.host == "appclusive") { oSession.host = "localhost:123"; }
    
  6. Save rules

  7. IMPORTANT: Activate automatic authentication. Otherwise your redirected requests will produce 401 responses because Fiddler won’t do the 401 challenge for you.

    fiddler-2

  8. Restart Fiddler

Now your requests will get recorded and you can debug the whole network traffic!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.