简体   繁体   中英

FTPWebRequest Error Win7 64bit vs Win2003 32bit

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM