FTPWebRequest failing - URGENT

Discussion in 'ASP .Net' started by BizWorld, Jun 15, 2007.

  1. BizWorld

    BizWorld Guest

    I am using .NET 2.0 new classed for FTP download purpose. I have
    requirement to connect with 3 different FTP and download all files
    list and see if file exist at my end. if not then i need to download.
    I am keeping my configuration in XML file so that i can use my same
    code and i simply iterate on my configuration data. 1st FTP connect
    works fine but 2nd FTP does not connect and return with following
    error message. After this failure when my code attemp to for the 3rd
    FTP, it works. but it also fail on Download file for 3rd FTP on some
    files. I could not find any specific reason for this exception. If i
    make my failing FTP as 1st one, so in general my second FTP request in
    my loop fails. i tested 3 ftp in internet explorer and they work fine.
    but in .NET 2.0 new classes i can see these un knonw behaviours. any
    suggestion on improving code or setting some other property which i am
    missing?????????????


    The remote server returned an error: (503) Bad sequence of commands.


    I further trace the error line, it is coming on following line,


    response = reqFTP.GetResponse()

    here is my code below which works well for 1st FTP Request but it
    fails on 2nd FTP.


    reqFTP = System.Net.FtpWebRequest.Create(New Uri("ftp://"
    + Me.FTP_Address))
    reqFTP.KeepAlive = True
    reqFTP.UseBinary = True
    reqFTP.Credentials = New
    System.Net.NetworkCredential(Me.FTP_User, Me.FTP_Password)
    reqFTP.Method =
    System.Net.WebRequestMethods.Ftp.ListDirectory
    response = reqFTP.GetResponse()
    reader = New
    System.IO.StreamReader(response.GetResponseStream())
    line = reader.ReadLine()
    While (Not line Is Nothing)
    result.Append(line)
    result.Append(",")
    line = reader.ReadLine()
    End While
    ' to remove the trailing ','
    result.Remove(result.ToString().LastIndexOf(","), 1)
    reader.Close()


    It is URGENT for me to resolve this issue, otherwise i will have to
    switch to a 3rd Party FTP component. I was excited about 2.0 new
    classes and i hope this issue will resolve with some one's feedback.
     
    BizWorld, Jun 15, 2007
    #1
    1. Advertising

  2. BizWorld

    BizWorld Guest

    I figured it out now. 1st of all i was not setting up KeepAlive
    property at all. Then i thought i should setup it as TRUE as default
    may be FALSE. but it did not work out. Then i setup it to FALSE
    explicitly and now every thing is working fine.
     
    BizWorld, Jun 15, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darqer
    Replies:
    1
    Views:
    1,309
    GinaM
    Nov 6, 2006
  2. Replies:
    2
    Views:
    535
  3. =?Utf-8?B?QmlsbA==?=

    Passing DefaultCredentials to an FtpWebRequest

    =?Utf-8?B?QmlsbA==?=, Mar 21, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    369
    =?Utf-8?B?QmlsbA==?=
    Mar 21, 2007
  4. daveh42
    Replies:
    1
    Views:
    848
    Scott Roberts
    Dec 18, 2007
  5. ThatsIT.net.au

    FtpWebRequest downloads

    ThatsIT.net.au, Dec 26, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    3,670
    ThatsIT.net.au
    Dec 27, 2008
Loading...

Share This Page