如何让System.Net.WebProxy到不能绕过本地的网址? [英] How to make System.Net.WebProxy to not bypass local urls?

查看:1119
本文介绍了如何让System.Net.WebProxy到不能绕过本地的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让提琴手工作, RestSharp 女巫使用 System.Http.WebProxy ,所以我希望它被设置为本地主机:8888 127.0.0.1:8888

I am trying to make Fiddler work with RestSharp witch uses System.Http.WebProxy, so I want it to be set to localhost:8888 or 127.0.0.1:8888

下面是code:

    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规定如下:

IsBypassed 方法来确定是否绕过代理   访问Internet资源时,服务器。

The IsBypassed method is used to determine whether to bypass the proxy server when accessing an Internet resource.

在BypassProxyOnLocal和BypassList属性控制返回   在 IsBypassed 方式的价值。

The BypassProxyOnLocal and BypassList properties control the return value of the IsBypassed method.

IsBypassed 返回真正在以下任一下列条件:

IsBypassed returns true under any of the following conditions:

      
  • 如果BypassProxyOnLocal是真正主机的是一个本地URI。本地请求   标识由缺乏一个周期的(。),在URI,如在   HTTP:// Web服务器/。

  • 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/".

如果主机匹配一个正EX pression在BypassList。

If host matches a regular expression in BypassList.

如果地址为null。

所有其他条件返回的错误

我不明白为什么在我的情况下,它返回的真正,这是一个错误?如何使它工作呢?谢谢!

I don't understand why in my case it returns true, is this a bug? How to make it work then? Thanks!

推荐答案

这是硬codeD的行为在.NET Framework中的HTTP客户端库的实现,镜像的行为的WinInet之前的Internet Explorer 9

This is hard-coded behavior in the implementation of the HTTP client library in the .Net framework, mirroring the behavior of WinInet prior to Internet Explorer 9.

请参阅监控流量从IE或.NET 为localhost从提琴手网页网站介绍了如何对付它。

See Monitor traffic to localhost from IE or .NET from the Fiddler web site explains how to deal with it.

这篇关于如何让System.Net.WebProxy到不能绕过本地的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆