.NET: HowTo enable WebService calls to be sent through Fiddler

Assuming you in Web.config have:

  <system.net>
    <defaultProxy>
      <proxy autoDetect="True" />
    </defaultProxy>
  </system.net>

Then in your transform file you change it with
Web.Debug.config:

  <system.net>
    <defaultProxy>
      <!-- Enable webservice calls to be sent through Fiddler  http://docs.telerik.com/fiddler/configure-fiddler/tasks/configuredotnetapp -->
      <proxy bypassonlocal="False" usesystemdefault="True" xdt:Transform="SetAttributes"/>
      <proxy xdt:Transform="RemoveAttributes(autoDetect)" />
    </defaultProxy>
  </system.net>

On the page, where you have a web service call you need to accept the Fiddler certificate, but only in your Debug mode:
*.aspx.cs:

        protected async void Page_Load(object sender, EventArgs e)
        {
#if DEBUG
            //Fix for accepting Fiddler cert: The remote certificate is invalid according to the validation procedure.
            //http://stackoverflow.com/questions/9983265/the-remote-certificate-is-invalid-according-to-the-validation-procedure
            ServicePointManager.ServerCertificateValidationCallback += (o, c, ch, er) => true;
#endif

The End.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: