Click to Rate and Give Feedback
TechNet
TechNet Library
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
FtpWebRequest..::.Proxy Property

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

Namespace:  System.Net
Assembly:  System (in System.dll)
Visual Basic
Public Overrides Property Proxy As IWebProxy
C#
public override IWebProxy Proxy { get; set; }
Visual C++
public:
virtual property IWebProxy^ Proxy {
    IWebProxy^ get () override;
    void set (IWebProxy^ value) override;
}
F#
abstract Proxy : IWebProxy with get, set
override Proxy : IWebProxy with get, set

Property Value

Type: System.Net..::.IWebProxy
An IWebProxy instance responsible for communicating with the FTP server.
ExceptionCondition
ArgumentNullException

This property cannot be set to nullNothingnullptra null reference (Nothing in Visual Basic).

InvalidOperationException

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

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.

The following code example displays this property value.

Visual Basic
Dim proxy As IWebProxy = request.Proxy
If proxy IsNot Nothing Then
    Console.WriteLine("Proxy: {0}", proxy.GetProxy(request.RequestUri))
Else
    Console.WriteLine("Proxy: (none)")
End If

Console.WriteLine("ConnectionGroup: {0}", If(request.ConnectionGroupName Is Nothing, "none", request.ConnectionGroupName))
C#
IWebProxy proxy = request.Proxy;
if (proxy != null)
{
    Console.WriteLine("Proxy: {0}", proxy.GetProxy(request.RequestUri));
} 
else
{
    Console.WriteLine("Proxy: (none)");
}

Console.WriteLine("ConnectionGroup: {0}",
    request.ConnectionGroupName == null ? "none" : request.ConnectionGroupName
);
Visual C++
IWebProxy^ proxy = request->Proxy;
if ( proxy )
{
   Console::WriteLine( "Proxy: {0}", proxy->GetProxy( request->RequestUri ) );
}
else
{
   Console::WriteLine( "Proxy: (none)" );
}

Console::WriteLine( "ConnectionGroup: {0}", request->ConnectionGroupName == nullptr ? "none" : request->ConnectionGroupName );

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Limitations via WebProxy are severe      nonnb   |   Edit   |   Show History
+1 agreed that having no write capabilities through an HttpProxy is a severe limitation. We are unable to rename or delete a file after downloading it.
Tags What's this?: Add a tag
Flag as ContentBug
Indeed a Joke      juFo   |   Edit   |   Show History
Same thoughts as the Joke! post. looking for another solution which will cost us again some money.
Tags What's this?: Add a tag
Flag as ContentBug
Joke!      Marcelo Araújo   |   Edit   |   Show History
It's a JOKE, this class don't supports upload with HTTP proxy. In this time i'll pay $249,00 to 3rd part API to use in professional aplication in a coportation tha uses an HTTP proxy.
Tags What's this?: Add a tag
Flag as ContentBug
ArgumentNullException is out of date, no longer thrown.      Scott R. Chamberlain   |   Edit   |   Show History
GlobalProxySelection.GetEmptyWebProxy is deprecated. The deprecation message says to use null for the proxy. If you use null on the proxy you will NOT get a ArgumentNullException.
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker