title: Accessing localhost FTP server via .Net
body: <p>I have an MVC application and am trying to access my localhost ftp server I set up in IIS- eventually it'll be accessing some other ftp server but I just want to try it out locally.  I wrote a c# function using FtpWebRequest but when I call GetResponse() it returns the error: "The remote server returned an error: (530) Not logged in." Not sure exactly how to log in as anonymous or non-anonymous user. Is the URL string formatted correctly if I have an FTP site in IIS called "MyFTPSite" and Anonymous Authentication is enabled? What should networkcredential be? The Files directory is a child of ftproot- do I need to add a virtual directory for the Files folder? Right now the physical path of the ftp site is set to C:\inetpub\ftproot. (In below code, localhost purposely spelled wrong b/c the site didn't want me to use a localhost url).</p>
  
  <pre><code> public override bool DownloadFile()
      {
          string fileName = System.IO.Path.GetFileName(this.UrlString);
  
          FtpWebRequest request = (FtpWebRequest)WebRequest.Create(this.UrlString);
          request.Method = WebRequestMethods.Ftp.DownloadFile;
  
          //anonymous logon
          request.Credentials = new NetworkCredential("anonymous", "&lt;my email&gt;");
  
          FtpWebResponse response = (FtpWebResponse)request.GetResponse();
  
          response.Close();
          return true;
  
      }
  
  FTPDownload download = new FTPDownload(@"ftp://lclhost/MyFTPSite/Files/w4.pdf");
  download.DownloadFile();
  </code></pre>