A
A
Alex Kay2014-10-23 12:39:47
FTP
Alex Kay, 2014-10-23 12:39:47

Why does ISA wrap the FTP server response in HTML?

I ask the FTP server for a list of files in a certain directory, but the response comes in html format, i.e. html, head, body tags, and then a list of links to files.
I'm creating a request here:

private FtpWebRequest CreateRequest(string uri, string method)
{
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri);

    request.Credentials = new NetworkCredential(username, password);
    request.Method = method;
    request.UseBinary = true;
    request.EnableSsl = false;
    request.UsePassive = true;

    if (useProxy)
    {
        request.Proxy = new WebProxy(proxyHost, proxyPort);
        request.Proxy.Credentials = new NetworkCredential(proxyUsername, proxyPassword, proxyDomain);
    }

    return request;
}

And so I request a list of files:
List<string> lines = new List<string>();

FtpWebRequest request = CreateRequest(uri, WebRequestMethods.Ftp.ListDirectory);

using (var response = (FtpWebResponse)request.GetResponse())
{
    using (var stream = response.GetResponseStream())
    {
        using (var reader = new StreamReader(stream, true))
        {
            while (!reader.EndOfStream)
            {
                lines.Add(reader.ReadLine());
            }
        }
    }
}

The result should be a list of files and folders. And I receive that specified above. Found the answer on some foreign site
It is likely that your admin has configured an HTTP proxy on the network. This proxy will talk using the FTP protocol to the destination FTP server. In FtpWebRequest, the client accesses the proxy over HTTP.
So, when a directory listing is returned from the FTP server, the HTTP proxy server changes the HTML and offers it to the client.
You should ask your admin if there is a private FTP proxy on the network, and use another instead.

I tested the program without the ISA server, directly. And got what I expected. And now the questions:
1. What can be done with FtpWebRequest so that you can go through a proxy, but the FTP protocol is used?
2. (Or) What can be done to ISA Server to stop wrapping the FTP response in html?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question