C# Asp.Net MVC文件上载到FTP返回550错误

C# Asp.Net MVC文件上载到FTP返回550错误,c#,model-view-controller,C#,Model View Controller,对不起我的英语,我希望我能解释我自己 当我们尝试从Internet Explorer将文件上载到FTP服务器时,返回550个错误代码。 但我们的代码在Chrome和Firefox上运行良好 这是我的方法 public void UploadImageToFtp(HttpPostedFileBase uploadfile, string path, int w, int h) { if (uploadfile != null) { var uploadurl = C

对不起我的英语,我希望我能解释我自己

当我们尝试从Internet Explorer将文件上载到FTP服务器时,返回550个错误代码。 但我们的代码在Chrome和Firefox上运行良好

这是我的方法

public void UploadImageToFtp(HttpPostedFileBase uploadfile, string path, int w, int h)
{
    if (uploadfile != null)
    {
        var uploadurl = ConfigurationManager.AppSettings.Get("FtpPath").ToString();
        var uploadfilename = uploadfile.FileName;
        var username = ConfigurationManager.AppSettings.Get("FtpUserName").ToString();
        var password = ConfigurationManager.AppSettings.Get("FtpPass").ToString();
        var img = Image.FromStream(uploadfile.InputStream, true, true);
        Bitmap bm = new Bitmap(img, w, h);
        string bmFolder = path;
        string ftppath = uploadurl + bmFolder + "/" + uploadfile.FileName;
        using (WebClient client = new WebClient())
        using (var ms = new MemoryStream())
        {
            bm.Save(ms, ImageFormat.Png);
            string directoryToCreate = uploadurl + path;
            WebRequest request = WebRequest.Create(directoryToCreate);
            request.Method = WebRequestMethods.Ftp.MakeDirectory;
            request.Proxy = null;
            request.Credentials = new NetworkCredential(username, password);
            client.Credentials = new NetworkCredential(username, password);
            client.UploadData(ftppath, ms.ToArray());
        }
    }
}

在粘贴的代码中,useragents之间唯一明显不同的是uploadfile的内容,在chrome/IE请求期间比较它,看看有什么不同。你忘记处理
bm
。这对IE来说是个问题吗?不,你的代码在服务器上,但需要完成。谢谢,我会做的。