[英]Trying to connect to an FTP server from Azure App service
I am trying to upload/download some files from Azure VM directly through a Azure App service, but the app returns this error:我正在尝试通过 Azure App 服务直接从 Azure VM 上传/下载一些文件,但该应用程序返回此错误:
System.Net.WebException: The remote server returned an error: (501) Syntax error in parameters or arguments.
System.Net.WebException:远程服务器返回错误:(501)参数或参数中的语法错误。
I am using blazor and this is the code from the that I use to upload:我正在使用 blazor,这是我用来上传的代码:
{
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://xxx.xxx.xxx.xxx/dir/file.conf");
request.Method = WebRequestMethods.Ftp.UploadFile;
request.UsePassive = false;
request.Credentials = new NetworkCredential("xxxx", "xxxx");
// convert contents to byte.
byte[] fileContents = Encoding.ASCII.GetBytes(str); ;
request.ContentLength = fileContents.Length;
using (Stream requestStream = request.GetRequestStream())
{
requestStream.Write(fileContents, 0, fileContents.Length);
}
using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
{
Console.WriteLine($"Upload File Complete, status {response.StatusDescription}");
}
}
If I do try from my PC it works properly.如果我确实从我的电脑上尝试它可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.