我试图使用
RestSharp使用System.Http.WebProxy使
Fiddler工作,所以我希望它设置为localhost:8888或127.0.0.1:8888
var webProxy = new WebProxy(new Uri("http://127.0.0.1:8888")) { BypassProxyOnLocal = false }; var bypassed = webProxy.IsBypassed(new Uri("http://127.0.0.1")); Console.WriteLine(bypassed);
MSDN声明如下:@H_301_3@
The IsBypassed method is used to determine whether to bypass the proxy
server when accessing an Internet resource.@H_301_3@The BypassProxyOnLocal and BypassList properties control the return
value of the IsBypassed method.@H_301_3@IsBypassed returns true under any of the following conditions:@H_301_3@
If BypassProxyOnLocal is true and host is a local URI. Local requests
are identified by the lack of a period (.) in the URI,as in
“http://webserver/”.@H_301_3@If host matches a regular expression in BypassList.@H_301_3@
If Address is null.@H_301_3@
All other conditions return false.@H_301_3@
解决方法
这是.Net框架中HTTP客户端库实现中的硬编码行为,反映了Internet Explorer 9之前WinInet的行为.
请参阅Fiddler网站上的Monitor traffic to localhost from IE or .NET解释如何处理它.@H_301_3@