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?
You can use Fiddler to create an HTTP session of the monitored web application. In Fiddler, go to Tools > Fiddler Options > HTTPS. Select Capture HTTPS CONNECTs and Decrypt HTTPS traffic. Go to File > Capture Traffic or press F12 to turn off capturing.
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.
The .NET Framework is hard-coded not to pass traffic to localhost through proxies. Try using http://localhost.fiddler:xxxx/
. This should route your request through fiddler so that it can capture the traffic. See Fiddler Documentation on this problem for more details and a couple other address options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With