How could I make Fiddler capture HTTP requests made by my MVC app to my ASP.NET Web API?

asp.net, asp.net-mvc, asp.net-web-api, fiddler

Solution

The Fiddler Docs addess this exact issue.

There are two parts to this

1 Set the MVC app to use fiddler as a proxy either in the web.config

<configuration>
 <system.net>
  <defaultProxy>
   <proxy bypassonlocal="false" usesystemdefault="true" />
  </defaultProxy>
 </system.net>
</configuration>

Or in code: `GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);`

2 Reference your api by machine name instead of localhost. This is because .net by default will not use a proxy when referencing something via localhost.

Problem

I have an ASP.NET MVC app that makes request to an ASP.NET Web API using the `System.Net.HttpClient` class. Both the MVC app, i.e. the client, and the ASP.NET Web API, i.e. the server, are hosted in IIS Express by the Visual Studio debugger when I start debugging them. I would like to have Fiddler capture the requests that are made by my MVC app to the ASP.NET Web API. Is this possible?

Original source