FtpWebRequest.Proxy Property


Gets or sets the proxy used to communicate with the FTP server.

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

Property Value

An IWebProxy instance responsible for communicating with the FTP server. On .NET Core, its value is null.


This property cannot be set to null.

A new value was specified for this property for a request that is already in progress.


The following code example displays this property value.

IWebProxy^ proxy = request->Proxy;
if ( proxy )
   Console::WriteLine( "Proxy: {0}", proxy->GetProxy( request->RequestUri ) );
   Console::WriteLine( "Proxy: (none)" );

Console::WriteLine( "ConnectionGroup: {0}", request->ConnectionGroupName == nullptr ? "none" : request->ConnectionGroupName );
IWebProxy proxy = request.Proxy;
if (proxy != null)
    Console.WriteLine("Proxy: {0}", proxy.GetProxy(request.RequestUri));
    Console.WriteLine("Proxy: (none)");

Console.WriteLine("ConnectionGroup: {0}",
    request.ConnectionGroupName == null ? "none" : request.ConnectionGroupName


On .NET Framework

The Proxy property identifies the IWebProxy instance that communicates with the FTP server. The proxy is set by the system by using configuration files and the Internet Explorer Local Area Network settings. To specify that no proxy should be used, set Proxy to the proxy instance returned by the GlobalProxySelection.GetEmptyWebProxy method. For more information about automatic proxy detection, see Automatic Proxy Detection.

You must set Proxy before writing data to the request's stream or getting the response. Changing Proxy after calling the GetRequestStream, BeginGetRequestStream, GetResponse, or BeginGetResponse method causes an InvalidOperationException exception.

The FtpWebRequest class supports HTTP and ISA Firewall Client proxies.

If the specified proxy is an HTTP proxy, only the DownloadFile, ListDirectory, and ListDirectoryDetails commands are supported.

On .NET Core

The FtpWebRequest.Proxy property is not supported. Setting the property has no effect. Getting the property value returns null.

Applies to

See also