Domanda

The following code works perfectly fine from my own machine (Win7 ISS7) but when I move it to a virtual server running IIS8 on a datacentre then I get the return code 150 (openingdata). I can access the ftp site via IE on this server. Is this a coding issue or configuration. Any help is greatly appreciated.

I've also tried changing UsePassive, UseBinary, no caching, to no effect and place it on an azure machine but to no avail.

private List<string> Browse()
{
  // Get the object used to communicate with the server.
  FtpWebRequest request = (FtpWebRequest)WebRequest.Create(m_Url);

  request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  result.Add("Timeout = " + request.Timeout.ToString());
  // This example assumes the FTP site uses anonymous logon.
  request.Credentials = new NetworkCredential(m_Username, m_Password);
  request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);

  if (m_Proxy != null)
  {
    request.Proxy = m_Proxy;
  }


  bool started = false;
  using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
  {
    Stream responseStream = response.GetResponseStream();

    using (StreamReader reader = new StreamReader(responseStream))
    {
      string line = reader.ReadLine();
      while (line != null)
      {
        result.Add(line);
        line = reader.ReadLine();
      }
    }
  }
  return result;
}
È stato utile?

Soluzione

Turned out it was a program error

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(m_Url);

should have been

FtpWebRequest request = (FtpWebRequest)*Ftp*WebRequest.Create(m_Url);

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top