HttpClientHandler.Proxy 属性

定义

获取或设置处理程序使用的代理信息。Gets or sets proxy information used by the handler.

public:
 property System::Net::IWebProxy ^ Proxy { System::Net::IWebProxy ^ get(); void set(System::Net::IWebProxy ^ value); };
public System.Net.IWebProxy Proxy { get; set; }
member this.Proxy : System.Net.IWebProxy with get, set
Public Property Proxy As IWebProxy

属性值

处理程序使用的代理信息。The proxy information used by the handler. 默认值为 nullThe default value is null.

注解

Proxy 属性标识用于处理对 Internet 资源的请求的 WebProxy 对象。The Proxy property identifies the WebProxy object to use to process requests to Internet resources. 若要指定不应使用代理,请将 Proxy 属性设置为 GetEmptyWebProxy 方法返回的代理实例。To specify that no proxy should be used, set the Proxy property to the proxy instance returned by the GetEmptyWebProxy method.

本地计算机或应用程序配置文件可以指定使用默认代理。The local computer or application config file may specify that a default proxy be used. 如果指定了 Proxy 属性,则 Proxy 属性中的代理设置将替代本地计算机或应用程序配置文件,并且处理程序将使用指定的代理设置。If the Proxy property is specified, then the proxy settings from the Proxy property override the local computer or application config file and the handler will use the proxy settings specified. 如果未在配置文件中指定代理,并且未指定 Proxy 属性,则处理程序将使用从本地计算机上的 Internet Explorer 继承的代理设置。If no proxy is specified in a config file and the Proxy property is unspecified, the handler uses the proxy settings inherited from Internet Explorer on the local computer. 如果 Internet Explorer 中没有代理设置,请求将直接发送到服务器。If there are no proxy settings in Internet Explorer, the request is sent directly to the server.

HttpClientHandler 类分析代理绕过列表,其中通配符字符从 Internet Explorer 继承,与绕过列表直接由 Internet Explorer 分析。The HttpClientHandler class parses a proxy bypass list with wildcard characters inherited from Internet Explorer the same as the bypass list is parsed directly by Internet Explorer. 例如,HttpClientHandler 类会将 Internet Explorer 中的 "nt *" 跳过列表分析为 "nt.*" 的正则表达式。For example, the HttpClientHandler class will parse a bypass list of "nt*" from Internet Explorer as a regular expression of "nt.*". 因此,http://nt.com 的 URL 会绕过使用 HttpClientHandler 类和使用 Internet Explorer 的代理。So a URL of http://nt.com would bypass the proxy using the HttpClientHandler class and using Internet Explorer.

HttpClientHandler 类支持本地代理跳过。The HttpClientHandler class supports local proxy bypass. 如果满足以下任一条件,则类将目标视为本地:The class considers a destination to be local if any of the following conditions are met:

  1. 目标包含平面名称(URL 中没有点)。The destination contains a flat name (no dots in the URL).

  2. 目标包含环回地址(LoopbackIPv6Loopback),或者目标包含分配给本地计算机的 IPAddressThe destination contains a loopback address (Loopback or IPv6Loopback) or the destination contains an IPAddress assigned to the local computer.

  3. 目标的域后缀与本地计算机的域后缀(DomainName)匹配。The domain suffix of the destination matches the local computer's domain suffix (DomainName).

适用于