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:    FTPTest  (with the correct IP address of course)

I get this message on this line of code

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

Any help would be appreciated
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If the value of the ServerAddr string is anything other than "FTPTest", try setting it to this value.


  Nayer Naguib
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 ""), you *must* include it, as it is a part of the hostname.


  Nayer Naguib

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.