Mono Class Library: System.Net Namespace

System.Net.WebProxy Class

Contains HTTP proxy settings for the System.Net.WebRequest class.

See Also: WebProxy Members

public class WebProxy : IWebProxy, System.Runtime.Serialization.ISerializable

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

Remarks

System.Net.WebRequest instances use System.Net.WebProxy instances to override the proxy settings in System.Net.GlobalProxySelection .

Note: Local requests are identified by the lack of a period (.) in the authority of the URI, as in "http://webserver/" versus "http://www.contoso.com/ ".

Example

The following example sets a System.Net.WebProxy for a System.Net.WebRequest. The System.Net.WebRequest instance uses the proxy to connect to external Internet resources.

C# Example

using System;
using System.Net;

public class WebProxyExample {

  public static void Main() {

    WebProxy proxyObject =
      new WebProxy("http://proxyserver:80/",true);
    WebRequest req =
      WebRequest.Create("http://www.contoso.com");
    req.Proxy = proxyObject;
  }
}

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.x.x, 1.0.5000.0, 2.0.0.0