HttpClientHandler.Proxy 属性

定义

获取或设置处理程序使用的代理信息。

public:
 property System::Net::IWebProxy ^ Proxy { System::Net::IWebProxy ^ get(); void set(System::Net::IWebProxy ^ value); };
public System.Net.IWebProxy Proxy { get; set; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public System.Net.IWebProxy? Proxy { get; set; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public System.Net.IWebProxy? Proxy { get; set; }
member this.Proxy : System.Net.IWebProxy with get, set
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Proxy : System.Net.IWebProxy with get, set
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("ios")>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("tvos")>]
member this.Proxy : System.Net.IWebProxy with get, set
Public Property Proxy As IWebProxy

属性值

处理程序使用的代理信息。 默认值为 null

属性

注解

Proxy 属性标识用于处理对 Internet 资源的请求的 WebProxy 对象。 若要指定不应使用代理,请将 Proxy 属性设置为 GetEmptyWebProxy 方法返回的代理实例。

本地计算机或应用程序配置文件可以指定使用默认代理。 如果指定了 Proxy 属性,则 属性中的 Proxy 代理设置将替代本地计算机或应用程序配置文件,处理程序将使用指定的代理设置。 如果在配置文件中未指定代理, Proxy 并且属性未指定,则处理程序将使用从本地计算机上的 Internet Explorer 继承的代理设置。 如果 Internet Explorer 中没有代理设置,则请求将直接发送到服务器。

HttpClientHandler 使用从 Internet Explorer 继承的通配符分析代理绕过列表,这与 Internet Explorer 直接分析绕过列表相同。 例如, HttpClientHandler 类将 Internet Explorer 中的“nt*”绕过列表解析为“nt.*”的正则表达式。 因此, 的 http://nt.com URL 将使用 类和 Internet Explorer 绕过代理 HttpClientHandler

HttpClientHandler 类支持本地代理绕过。 如果满足以下任一条件,该类会将目标视为本地目标:

  1. 目标包含平面名称(URL 中不含点)。

  2. 目标包含环回地址(LoopbackIPv6Loopback),或者目标包含分配给本地计算机的 IPAddress

  3. 目标的域后缀匹配本地计算机的域后缀 (DomainName)。

适用于