繁体   English   中英

FtpWebRequest引发System.Net.WebException:远程服务器返回错误:(530)未登录

[英]FtpWebRequest throws System.Net.WebException: The remote server returned an error: (530) Not logged in

我有一个Windows服务,试图在我的FTP服务器上创建一个文件夹。 该服务在本地运行良好,没有任何问题。 但是,当我尝试在服务器上执行时,我得到了530。真正奇怪的是,我创建了一个.aspx小页面,该页面运行相同的代码并且可以正常工作。 它仅在我的服务代码中失败。

            var ftpLocation = ConfigurationManager.AppSettings["FtpLocation"];
        var ftpUserName = ConfigurationManager.AppSettings["FtpUserName"];
        var ftpPassword = ConfigurationManager.AppSettings["FtpPassword"];

        var request = (FtpWebRequest)WebRequest.Create(ftpLocation);
        request.Method = WebRequestMethods.Ftp.MakeDirectory;
        request.EnableSsl = true;
        request.Credentials = new NetworkCredential(ftpUserName, ftpPassword);
        try
        {
            logger.Debug("Calling MakeDirectory for " + ftpPath);

            using (var response = (FtpWebResponse)request.GetResponse())
            {
                if (response.StatusCode != FtpStatusCode.PathnameCreated)
                    throw new ApplicationException(string.Format("FTP failed with the following response: {0} - {1}",
                        response.StatusCode, response.StatusDescription));
                response.Close();
            }
            logger.Debug("Calling MakeDirectory for " + ftpPath);

        }

我还应该注意,我要创建的目录中有一个空格,但是同样,它在我的aspx页面上可以100%正确地工作。

啊! 我至少看了十几遍密码。 轮到我们的部署服务器在部署时正在替换密码中的3个字符

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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