Re: ftp request through ftp proxy



The documentation for the Proxy property on the FtpWebRequest class
states:

The FtpWebRequest class supports HTTP and ISA Firewall Client proxies.

This leads me to believe that these are the only proxies it supports.

Also, when using an HTTP proxy, you are limited to the methods that you
can use:

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

I don't know if it supports an FTP proxy, but you might try and create a
URI with the FTP scheme, address, and port, and pass that to your WebProxy
instance and see if that works.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"squall" <squall2022@xxxxxxxxx> wrote in message
news:5f19839f-926b-4733-ab0c-58fd43539eb9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I have to upload files on a ftp server through a ftp proxy with
Dotnet.
I have a 'System.InvalidOperationException' with this message : "The
requested FTP command is not supported when using HTTP proxy". Is
there a solution to use a FTP proxy and not a HTTP proxy ?

Thanks
Marc

My code (in CLI/C++, but the same in C#) :

// Get the object used to communicate with the server.
FtpWebRequest^ request = (FtpWebRequest^)WebRequest::Create("ftp://
xxx.xxx.com"); // Uri of ftp server
request->Method = WebRequestMethods::Ftp::UploadFile;

// FTP Proxy
request->Proxy = gcnew WebProxy("ftpProxyHostname", 21);

request->Credentials = gcnew
NetworkCredential("ftpServerUser","password");

// Copy the contents of the file to the request stream.
StreamReader^ sourceStream = gcnew StreamReader(exportDirectory +
zipName);
array<Byte>^ fileContents = Encoding::UTF8->GetBytes(sourceStream-
ReadToEnd());
sourceStream->Close();
request->ContentLength = fileContents->Length;

Stream^ requestStream = request->GetRequestStream();
requestStream->Write(fileContents, 0, fileContents->Length);
requestStream->Close();

FtpWebResponse^ response = (FtpWebResponse^)request->GetResponse();


.



Relevant Pages

  • RE: Which Proxy Server....
    ... HTTP, FTP, Telnet, SSL, NNTP and E-Mail all use TCP and can be easily ... MANY proxy servers exists for this purpose. ...
    (Security-Basics)
  • [SubWeb] NEW http proxy/reverse proxy
    ... SubWeb is a proxy. ... HTTP flows in the line of HTTPush, ... This list is provided by the SecurityFocus Security Intelligence Alert ...
    (Pen-Test)
  • Re: Error 49, socket problem?
    ... lo0: flags=8049mtu 16384 ... proxy: HTTP: attempt to connect to 127.0.0.1:81 failed ... based apps on the server fail, yet nothing in /var/log/messages indicating a ...
    (freebsd-net)
  • Re: HTTPS Using Web Proxy
    ... couple of the sites using the direct access method. ... Error Code: 504 Proxy Timeout. ... On the internal network properties / Web proxy page I enabled SSL on ... I added HTTPS to the same rule as HTTP is working on; ...
    (microsoft.public.isa)
  • Re: ISA 2004 Server Errors
    ... Tunneling SSL Through a WWW Proxy ... CONNECT is really a lower-level function than the rest of the HTTP methods, ... Through ISA Server ...
    (microsoft.public.isa)