locked
FileUpload problem on a FTP server RRS feed

  • Question

  • User-1142415031 posted

    I created a ASP.Net application in which I am uploading a file on a FTP SERVER.

    Its works fine when I am running it from CASINI server (ASP.Net Server). But when hosted in IIS it is giving following error:

    The remote name could not be resolved: 'ftp.ServerName'   at System.Net.FtpWebRequest.GetRequestStream()
    webEx.Response - > System.Net.FtpWebResponse
    webEx.Status - > NameResolutionFailure
    webEx.Message - > The remote name could not be resolved: 'ftp.ServerName'

     

    On changing the server name with its IP address, following error comes:

    Unable to connect to the remote server   at System.Net.FtpWebRequest.GetRequestStream()
    webEx.Response - > System.Net.FtpWebResponse  
    webEx.Status - > ConnectFailure  
    webEx.Message - > Unable to connect to the remote server


    Note: We are already using the Microsoft Firewall Client for ISA Server.

    Code Snippet:

    Uri serverUri = new Uri(ftpPath + ftpFileName);

    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
    request.Method = WebRequestMethods.Ftp.UploadFile;
    request.Proxy = null;

     

    FileStream stream = File.OpenRead(fileName);
    byte[] buffer = new byte[stream.Length];
    stream.Read(buffer, 0, buffer.Length);
    stream.Close();

     

    Stream reqStream = request.GetRequestStream();
    reqStream.Write(buffer, 0, buffer.Length);
    reqStream.Close();

    P.S: I am reposting it here... earlier i posted it under following category..
    Home › Forums › IIS 5.x & 6.0 › ASP.NET Administration › FileUpload problem on a FTP server

    Friday, November 7, 2008 6:37 AM

Answers

  • User1064866747 posted

    according to the error message "The remote name could not be resolved: 'ftp.ServerName'"   it seems that ftp.ServerName is not resolving to your FTP server IP address. Also you should have IIS5 and IIS6 on different server, as you have ISA on your IIS 6 server make sure you enable FTP ports in it. If its enabled then you should be able to telnet and tracert should be completed successfully, have you checked for telnet and tracert ?

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, November 9, 2008 12:34 PM

All replies

  • User-1341446551 posted

     Are you able to FTP to the server manually? I mean without using your script... Tried using the FQDN??

    Friday, November 7, 2008 8:12 AM
  • User-1142415031 posted

    Yes, I am able to upload file successfuly via console application or ASP.Net web application.

    New point that i came to know that ... same code is working fine on (Win XP + IIS 5) but not on (Win Server 2003  + IIS 6).

    In (WinXP + II5) followed same steps... create a ASP.Net web app and publish it in IIS... and its working.

     

    Friday, November 7, 2008 8:41 AM
  • User1064866747 posted

    according to the error message "The remote name could not be resolved: 'ftp.ServerName'"   it seems that ftp.ServerName is not resolving to your FTP server IP address. Also you should have IIS5 and IIS6 on different server, as you have ISA on your IIS 6 server make sure you enable FTP ports in it. If its enabled then you should be able to telnet and tracert should be completed successfully, have you checked for telnet and tracert ?

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Sunday, November 9, 2008 12:34 PM