Answer the question
In order to leave comments, you need to log in
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;
}
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());
}
}
}
}
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.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question