返回顶部

收藏

C# 在.net中使用IE代理

更多
Configure a .NET application to use Fiddler?
If you're coding a .NET application, K Scott Allen's blog shows a simple way to hook Fiddler temporarily for debugging purposes:

GlobalProxySelection.Select = new WebProxy("127.0.0.1", 8888);

Note that you might not even need to do this-- The Framework should autodetect the WinINET proxy when the .NET application starts.  Note that this means that Fiddler must be started BEFORE your application if your application is to autodetect Fiddler.

You may specify a proxy inside the yourappname.exe.config file.

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

See http://msdn.microsoft.com/en-us/magazine/cc300743.aspx for more on this topic.

Another setting to check is inside machine.config. Ensure the following is present:

<proxy usesystemdefault="true" />

If all else fails, you can manually specify the proxy on an individual WebRequest object, like so:

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

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:

Does not show in Fiddler: http://localhost/X509SignCodeService/X509SigningService.asmx

Shows in Fiddler: http://mymachine/X509SignCodeService/X509SigningService.asmx
//该片段来自于http://outofmemory.cn

标签:c#,.net,网络

收藏

0人收藏

支持

0

反对

0

发表评论