官方版

Configure .NET Applications

To allow the .NET Framework to automatically connect to Fiddler, start Fiddler before starting the .NET application.
To temporarily connect a .NET application to Fiddler, use the GlobalProxySelection class to set a proxy:
{WJ)B}4}OR5J~PXK2~2VU}P.png
Or, specify a proxy inside the yourappname.exe.config file.

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

    1. <configuration>
    2. <system.net>
    3. <defaultProxy>
    4. <proxy bypassonlocal="false" usesystemdefault="true" />
    5. </defaultProxy>
    6. </system.net>
    7. </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:

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

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

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

    Note: Important: Regardless of other settings, .NET will always bypass the Fiddler 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:

3VZ~H{M%6X`17X%BVPHK`UI.png

http://localhost/X509SignCodeService/X509SigningService.asmx

This URL will appear in Fiddler:
WX1DU]HV{NGMU}%@YVEH($G.png

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

  1. netsh winhttp set proxy 127.0.0.1:8888

To remove the proxy use the following

  1. netsh winhttp reset proxy

谷歌翻译版

配置.NET应用程序

若要使.NET Framework自动连接到Fiddler,请在启动.NET应用程序之前启动Fiddler。.
要将.NET应用程序临时连接到Fiddler,请使用GlobalProxySelection类设置代理:
{WJ)B}4}OR5J~PXK2~2VU}P.png
或者,在yourappname.exe.config文件中指定一个代理.

  • 如果.NET应用程序以您当前的用户帐户运行,请在配置部分中添加以下内容:

    1. <configuration>
    2. <system.net>
    3. <defaultProxy>
    4. <proxy bypassonlocal="false" usesystemdefault="true" />
    5. </defaultProxy>
    6. </system.net>
    7. </configuration>

    有关此主题的更多信息,请参见MSDN。

  • 如果.NET应用程序以其他用户帐户(例如Windows服务)运行,请编辑machine.config文件:

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

    或者,手动在单个WebRequest对象上指定代理:

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

    注意 重要说明:无论其他设置如何,.NET始终会针对包含localhost的URL绕过Fiddler代理。 因此,不要使用localhost,而是更改代码以引用计算机名称。 例如::

  • 此URL将不会出现在Fiddler中:

3VZ~H{M%6X`17X%BVPHK`UI.png

http://localhost/X509SignCodeService/X509SigningService.asmx

该网址将显示在Fiddler中:
WX1DU]HV{NGMU}%@YVEH($G.png

http://mymachine/X509SignCodeService/X509SigningService.asmx

配置.NET Core应用程序

在命令行的netsh工具通过以下命令设置代理

  1. netsh winhttp set proxy 127.0.0.1:8888

要删除代理请使用以下命令

  1. netsh winhttp reset proxy