0
即時通訊從Azure web服務web應用程序使用簡單的ASP.net應用程序 我有這樣的代碼,它應該使我能夠將文件上傳到我運行相同的服務器web應用程序。 這樣的:使用ASP.net mvc上傳文件到azure iis web應用程序失敗
try
{
FtpWebRequest r = (FtpWebRequest)WebRequest.Create("ftp://www.ftp.azurewebsites.windows.net/site/wwwroot/myfiles/FTP");
r.KeepAlive = true;
r.UseBinary = true;
r.Method = WebRequestMethods.Ftp.UploadFile;
r.Credentials = new NetworkCredential("myapp\userA","password123");
FileStream fs = System.IO.File.OpenRead(source + "sourceFile.json");
byte[] fileBytes = new byte[fs.Length];
fs.Read(fileBytes, 0, fileBytes.Length);
fs.Close();
r.ContentLength = fileBytes.Length;
r.UsePassive = false;
r.UseBinary = true;
r.ServicePoint.ConnectionLimit = fileBytes.Length;
r.EnableSsl = false;
using (Stream requestStream = r.GetRequestStream())
{
requestStream.Write(fileBytes, 0, fileBytes.Length);
requestStream.Close();
}
FtpWebResponse rs = (FtpWebResponse)r.GetResponse();
rs.Close();
catch (WebException ex)
{
throw new Exception((ex.Response as FtpWebResponse).StatusDescription);
}
2怪事happning,
當我運行從Visual Studio代碼在本地我沒有拋出異常 但文件永遠不會創建 1。
2.當我從我的web應用程序即時得到運行這段代碼:
500 (Internal Server Error)
這裏有什麼問題?
你解決了這個問題嗎? –