语言

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")]
[System.Runtime.Versioning.UnsupportedOSPlatform("ios")]
[System.Runtime.Versioning.UnsupportedOSPlatform("tvos")]
public System.Net.IWebProxy? Proxy { get; set; }
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public System.Net.IWebProxy? Proxy { get; set; }
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
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
member this.Proxy : System.Net.IWebProxy with get, set
Public Property Proxy As IWebProxy

属性值

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

特性

注解

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

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

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

  • 目标包含平面名称(URL 中没有点)。
  • 目标包含环回地址(Loopback 或)或 IPv6Loopback目标包含 IPAddress 分配给本地计算机的地址。
  • 目标的域后缀与本地计算机的域后缀 (DomainName) 匹配。

适用于