Question

I have a class that FTPs a file to a remote server, the code looks like this:

FtpWebRequest oFTPRequest = (FtpWebRequest)WebRequest.Create(sFTPServer + sTargetFolderAndFileName);
oFTPRequest.Method = WebRequestMethods.Ftp.UploadFile;
oFTPRequest.Credentials = new NetworkCredential(sFTPUserName, sFTPPassword);
oFTPRequest.UseBinary = true;

Stream requestStream = oFTPRequest.GetRequestStream();
// uploads file...

The all works perfectly when running from the dev environment, however when I compile and place onto the server it fails with an FTP Error "The remote server returned an error: (530) Not logged in.".

The username, password, ftp server and path information are all identical to the code running in dev environment - so I know they are correct.

The only two differences I can see are: - The code is now compiled - My (dev) PC is Windows 7 64bit and the target server is Windows 2003 32bit

All using .NET 4.0 / VS2010

Why is it working on one and not the other?

Was it helpful?

Solution

I found the problem. The Windows 2003 Server is a Small Business Server, part of the configuration used the same name as the remote server (domainname.com) - therefore when the FTP request was sent it was looping back on itself and failing to login, instead of connecting to the remote server.

Oddly, Filezilla didn't experience the same issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top