Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to FTP through Dynamic DNS Service (DynDNS) using VB .NET 3.5?

Posted on 2012-03-31
8
Medium Priority
?
1,176 Views
Last Modified: 2012-04-07
I am successfully using FtpWebRequest to transfer files between the local computer and my web site (hosted off-site).

            ftpReq = FtpWebRequest.Create(str_URL)
            ftpReq.KeepAlive = False
            ftpReq.Credentials = New NetworkCredential(p_str_User_ID, p_str_Password)
            ftpReq.Method = WebRequestMethods.Ftp.ListDirectory
            ftpReq.Proxy = Nothing
            ftpReq.UsePassive = False
            ftpReq.Timeout = p_int_Timeout

            Dim sr As New StreamReader(ftpReq.GetResponse().GetResponseStream())

I can remotely access the office server (a DNS-323) using the connection string "ftp://<userID>:<password>@<ipAddress>:<port>/".  The office is served via Verizon FIOS and gets a dynamic DNS assigned at the whim of Verizon.

I would like to accomplish the same thing through DynDNS remote access.  I can successfully do this through IE9 using the connection string "ftp://<myHostName>.dnsalias.com:<port>/".

HOWEVER, when I try this using FtpWebRequest, I get the message "The data connection was made from an address that is different than the address to which the ftp connection was made".

How do I need to tweak FtpWebRequest to make this work?

Thank you in advance for your help!

George
0
Comment
Question by:CIW_George
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 37792547
This will be fixed in NETFX 4.0. FtpWebRequest will ignore the IP address from the PASV response string. This will be similar behavior to the IPv6 EPSV response string. We will continue to connect to the original IP address given in the Uri to the request.
http://connect.microsoft.com/VisualStudio/feedback/details/97409/ftpwebre
0
 

Author Comment

by:CIW_George
ID: 37793831
Ok...

You're referring to NETFX 4.0 in the future tense, even though the ISO image has a release date of 5/19/2010 (almost two years ago).

Does that mean that this "problem" has not been "fixed" yet?  I've seen a number of posts indicating that this problem may still exist in 4.0, but I'm not sure about the credibility of those reporting this.

I would hate to have my clients be forced to install NETFX 4.0 (assuming the problem has been fixed) just to support the FtpWebRequest and ignore the IP address from the PASV response string.

Is there an "Option 3.5 Solution" floating around that is compatible with .NET 3.5?

Or am I missing something here?

Thank you.

George
0
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 37793992
Try it and see if it has been fixed. There is conflicting claims, one being that it will not be fixed due to security concerns. We decided not to support this scenario for security reasons (transparently connecting to a host other than the one specified by the application). (2005 response), the other saying that it will be fixed (2009)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:CIW_George
ID: 37794037
I suppose I could install VS 2010, which I did purchase a while ago but I've been quite happy with VS 2008.

And then I could install NETFX 4.0, which I just downloaded.

Other than being the only means to support NETFX 4.0, which may or may not address the FtpWebRequest issue, I have no real motivation to install VS 2010 at this time.

Maybe after the weekend, somebody will step forward and say "yup, it's working great in NETFX 4.0", or "nope, still the same old problems as in 3.5."

That's kinda' the answer I'm looking for.  Or a 3.5 solution.

George
0
 

Author Comment

by:CIW_George
ID: 37794063
The following was posted by an individual about six weeks (7/1/2009) after the the quote you provided from the Microsoft Network Class Library Team (5/21/2009):

"I have downloaded NETFX 4.0 and Visual Studio 2010 Beta version to try out if the fix has been implemented. The exception is still being thrown."

And another post on Microsoft Connect on 4/19/2011:

"So no fix and no workaround. Hopeless."

Still looking for information less than a year old...
0
 

Accepted Solution

by:
CIW_George earned 0 total points
ID: 37796940
Solution (at least for me):

    Dim p_Ping as New Ping
    Dim p_Reply as PingReply
    dim str_IP_Address as String

    p_Reply = p_Ping.Send(<myHostName>.dnsalias.com)

    str_IP_Address = p_Reply.Address.ToString

Now str_IP_Address contains the "real" IP address of the FTP server and FtpWebRequest can be used with str_IP_Address and without exceptions being thrown.

Problem solved within the limitations of .NET 3.5.
0
 
LVL 83

Expert Comment

by:David Johnson, CD, MVP
ID: 37797082
I'd have working over elegant any day!
0
 

Author Closing Comment

by:CIW_George
ID: 37818669
The answers provded by others were simply Microsoft "promises" - no solution was provided.

My  solution is probably not the most glamorous, and maybe not the best solution, but it answers the original question.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

671 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question