2

I have an ASP MVC4 site. I have to create a folder on ftp server and I use this code:

FtpWebRequest ftpWebRequest = (FtpWebRequest)WebRequest.Create("ftp://mysite.altervista.org/newfolder");
ftpWebRequest.Method = WebRequestMethods.Ftp.MakeDirectory;       
ftpWebRequest.UsePassive = true;
ftpWebRequest.EnableSsl = true;
ftpWebRequest.Credentials = new NetworkCredential("userTest", "psw123456");
ftpWebRequest.KeepAlive = true;
ftpWebRequest.UseBinary = true;
using (var resp = (FtpWebResponse)ftpWebRequest.GetResponse())
 {
  Console.WriteLine("Result: " + resp.StatusCode);
 }

When I run my site in localhost everything works fine, but when I Publish my site to Azure Website, it returns me an exception: "The remote server returned an error: (530) Not logged in." I think that the problem is not in my code, do I have to change some setting in Azure?

Thank you in advance

Lelezeus
  • 498
  • 3
  • 17

2 Answers2

1

remove below 2 lines and try again

ftpWebRequest.UsePassive = true;
ftpWebRequest.EnableSsl = true;
Neel
  • 11,625
  • 3
  • 43
  • 61
  • Nothing has changed, with localhost works, on Azure it returns the same error: “The remote server returned an error: (530) Not logged in.” – Lelezeus Jun 28 '14 at 11:22
  • can you try putting your username as "anonymous" and try again @Lelezeus – Neel Jun 28 '14 at 11:34
  • Done, but with anonymous user, both localhost and azure don't work – Lelezeus Jun 28 '14 at 11:46
  • may be anything useful here http://stackoverflow.com/questions/14968938/ftpwebrequest-530-error-not-logged-in-issue?rq=1? @Lelezeus – Neel Jun 28 '14 at 12:05
  • Thank you, but I have already checked everything about username & passw .. the point is that in localhost everything works (so the credentials are correct) but on azure don't – Lelezeus Jun 29 '14 at 18:26
  • Hi all, have you find a way to do this (sending file using FTP from WebJobs or WebApp) ? thanks in advance – Sanpas Oct 18 '18 at 13:20
0

Have tried to check some settings in your FTP server? Maybe, the incoming connections are blocked.

spaghettifunk
  • 1,936
  • 4
  • 24
  • 46