NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Using a Proxy

If your site uses an HTTP proxy to provide access to the Web, you can configure the global proxy selection to enable your application to communicate with the Web proxy. The following code will create a global proxy instance that will enable any HttpWebRequest instance to use this proxy to communicate with the Internet. It assumes that the proxy host is named "webproxy" and that it communicates on port 80, the standard HTTP port:

DefaultControlObject proxyObject = 
   new DefaultControlObject("webproxy",80);
GlobalProxySelection.Select = proxyObject;

Each HttpWebRequest can specify an individual proxy by setting its Proxy property to an instance of the ProxyData class. This individual proxy setting will override the global proxy selection when OverrideSelectProxy is true; otherwise the global proxy selection will be used.

// Create the ProxyData object
ProxyData proxyObject = new ProxyData();
// Set the proxy host and port.
proxyObject.HostName = "webproxy";
proxyObject.Port = 80;
// Override the global proxy setting
proxyObject.OverrideSelectProxy = true;

req.Proxy = proxyObject;