• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 427
  • Last Modified:

Connecting to FTP site via VB.NET

Using IIS I created an FTP site called FTPTest.  The site allows anonymous connections.  If I type 'ftp://localhost/ftptest' into IE, I can see the documents and there are no problems.  However, if I attempt to do the same in code I get the following message:

System.Net.Sockets.SocketException: The requested name is valid and was found in the database, but does not have the correct associated data being resolved for
at System.Net.Dns.GetHostName
at  System.Net.Dns.Resolve, etc....

I have added the following line to my Hosts file:

xx.xx.xxx.xx    FTPTest  (with the correct IP address of course)

I get this message on this line of code


Try
         BuildConnection(Dns.Resolve(ServerAddr).AddressList(0), FtpPort) <----------------  Here
Catch err As Exception
            MsgBox(err.ToString())
            Me.Dispose()
End Try


Any help would be appreciated
0
JRossi1
Asked:
JRossi1
  • 2
1 Solution
 
nayernaguibCommented:
If the value of the ServerAddr string is anything other than "FTPTest", try setting it to this value.

_______________

  Nayer Naguib
0
 
nayernaguibCommented:
Setting ServerAddr to "ftp://somehostname" or "http://somehostname" will also throw an exception.

Otherwise, if you would like to set ServerAddr to "localhost/FTPTest", then you should modify the hostname in the hosts file to become "localhost/FTPTest".

Note that when testing your code using other FTP hostname values, you should not use the "ftp://" prefix. This prefix specifies the *protocol*, which has nothing to do with the hostname. However, if the hostname includes the prefix "ftp." (as in "ftp.simtel.net"), you *must* include it, as it is a part of the hostname.

_______________

  Nayer Naguib
0
 
JRossi1Author Commented:
Sorry for not answering sooner.  I have been out sick.  Anyway, your advice regarding the Hosts file worked.  However, the FTP site is rejecting my password.  I have the 'Allow Anonymous Access' checked and I typed in my email address as the password, but it is not accepted.  Is there some default password that is used when the 'Allow Anonymous Access' is checked?

Thanks...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now