0
我在ASP.NET webservice中有一個簡單的類。它運行在我的本地系統,甚至在我已經設置了開發環境很好,但每當我嘗試發送生產服務器我得到下面的錯誤上的一個文件:在IIS7.5和.NET 4.0上使用FTPWebRequest時出錯
Exception Error: The underlying provider failed on Open.
這裏是代碼被稱爲:
public class FTPHelper
{
public static string SendFile(string ftpuri, string username, string password, string ftppath, string filename, byte[] datatosend)
{
if (ftppath.Substring(ftppath.Length - 1) != "/")
{
ftppath += "/";
}
FtpWebRequest ftp = (FtpWebRequest) FtpWebRequest.Create(ftpuri + ftppath + filename);
ftp.Method = WebRequestMethods.Ftp.UploadFile;
ftp.Credentials = new NetworkCredential(username, password);
ftp.UsePassive = true;
ftp.ContentLength = datatosend.Length;
Stream requestStream = ftp.GetRequestStream();
requestStream.Write(datatosend, 0, datatosend.Length);
requestStream.Close();
FtpWebResponse ftpresponse = (FtpWebResponse)ftp.GetResponse();
return ftpresponse.StatusDescription;
}
}
如何解決此問題。服務器是在Windows 2008 Server上運行的IIS 7.5。我正在使用.NET 4.0。是否有一個簡單的原因,爲什麼FtpWebResponse不會工作?
如果這是一個安全問題,那麼有沒有辦法解決它?我需要馬上得到這個工作。
我大吃一驚,一個星期後,沒有一個人可以幫助我與此。即使有獎金,也沒有人有答案。 – stephenbayer