如何:重写全局代理选择How to: Override a Global Proxy Selection

此示例将 WebRequest 发送到 www.contoso.com,其在端口 80 上使用名为 alternateproxy 的代理服务器替代全局代理选择。This example sends a WebRequest to www.contoso.com that overrides the global proxy selection with a proxy server named alternateproxy on port 80.

示例Example

WebRequest req = WebRequest.Create("http://www.contoso.com/");  
req.Proxy = new WebProxy("http://alternateproxy:80/");  
Dim req As WebRequest = WebRequest.Create("http://www.contoso.com/")  
req.Proxy = New WebProxy("http://alternateproxy:80/")  

编译代码Compiling the Code

此示例需要:This example requires:

请参阅See also