Wiki

Case Status
Log In

Wiki

 
Fiddler
  • RSS Feed

Last modified on 8/13/2024 11:04 AM by User.

Tags:

Fiddler

Configure .NET Applications

To allow the .NET Framework to automatically connect to Fiddler, start Fiddler Classic before starting the .NET application.

To temporarily connect a .NET application to Fiddler Classic, use the GlobalProxySelection class to set a proxy:

System.Net.WebRequest.DefaultWebProxy = new System.Net.WebProxy("127.0.0.1", 8888);

Or, specify a proxy inside the yourappname.exe.config file.

for VS2019+ a config can be found in <project>\.vs\<projectname>\config

  • If the .NET application is running in your current user account, add the following content inside the configuration section:

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

See MSDN for more on this topic.

  • If the .NET application is running in a different user account (for example, a Windows service), edit the machine.config file:

    <!-- The following section is to force use of Fiddler Classic for all applications, including those running in service accounts -->  <system.net>
     <defaultProxy>
      <proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
     </defaultProxy>
    </system.net>

Or, manually specify the proxy on an individual WebRequest object:

    objRequest = (HttpWebRequest)WebRequest.Create(url);
    objRequest.Proxy= new WebProxy("127.0.0.1", 8888);

Note: Important: Regardless of other settings, .NET will always bypass the Fiddler Classic proxy for URLs containing localhost. So, rather than using localhost, change your code to refer to the machine name. For instance:

  • This URL will not appear in Fiddler:

    http://localhost/X509SignCodeService/X509SigningService.asmx

  • This URL will appear in Fiddler:

    http://mymachine/X509SignCodeService/X509SigningService.asmx

Configure .NET Core Applications

Setup the proxy via netsh tool in commmand line the following way

see Netsh Docs for more info on this topic

    netsh winhttp set proxy 127.0.0.1:8888

To remove the proxy use the following

    netsh winhttp reset proxy

IIS HTTPS

You need to configure Fiddler to work as a reverse HTTPS proxy for the IIS server. The procedure is described here. I am going to write it here, as well, for your convenience. Here are the steps to achieve this:

  1. Configure the IIS to listen to a new port (e.g. 444)
  2. Inside Tools > Fiddler Options > Connections, tick Allow Remote Clients to Connect. Restart Fiddler.
  3. Inside Fiddler's QuickExec box, type !listen 443 ServerName where ServerName is whatever the server's hostname is; for instance, for https://foobar you would use foobar for the server name.
  4. Inside your FIddlerScript's OnBeforeRequest method , add:

 

if ((oSession.HostnameIs("foobar")) &&
    (oSession.oRequest.pipeClient.LocalPort == 443) ) 
{
   oSession.host = "foobar:444";
}

 

The !listen command instructs Fiddler to create a new endpoint that will perform a HTTPS handshake withe the client upon connection and Fiddler will present itself as the foobar server. The default proxy endpoint doesn't do that because when a proxy receives a connection for HTTPS traffic it gets a HTTP CONNECT request instead of a handshake.

One more thing - if you do not want to configure the IIS serve to listen to a different port you can leave it listening on 443 and instead open the new Fiddler endpoint on 444 for example like this: !listen 444 foobar Then in the OnBeforeRequest method if the LocalPort is 444 you have to change the host to "foobar:443". And finally, from your browser you will have to navigate to https://foobar:444 in order to capture the request and response with Fiddler.