How to use Fiddler/Charles when debugging .NET MVC Applications

Add this to the system.net section in your web.config
<defaultProxy> <proxy proxyaddress="http://127.0.0.1:8888" /> </defaultProxy>

127.0.0.1:8888 is the default address that Charles/Fiddler uses.

If you are doing requests against a site that uses HTTPS you can get some certificate errors like this one:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Just add this line of code right before you are executing your WebClient requests
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

You could also add the following to your web.config

<configuration> <system.net> <settings> <servicePointManager checkCertificateName="false" checkCertificateRevocationList="false" /> </settings> </system.net> </configuration>

How to use Fiddler/Charles when debugging .NET MVC Applications
Share this