By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

FTP : The remote server returned an error: (530) Not logged in.

donilourdu
P: 53
hi ,

This is doni. I am facing problem in follwing code. I am trying to encorparate ftp server. While running it shows following error.

The remote server returned an error: (530) Not logged in.

The username & password are correct

the code

Expand|Select|Wrap|Line Numbers
  1. protected void subFtp(string path,string uname,string pwd,string dname)
  2.     {
  3.         FtpWebRequest req = (FtpWebRequest)WebRequest.Create(path);
  4.         req.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  5.         req.Credentials = new NetworkCredential(uname, pwd,dname);
  6.         FtpWebResponse response = (FtpWebResponse)req.GetResponse();
  7. //'here is the Error shows
  8.         Stream responseStream = response.GetResponseStream();
  9.         StreamReader reader = new StreamReader(responseStream);
  10.         response.StatusDescription);
  11.         Response.Write(reader.ReadToEnd());
  12.         reader.Close();
  13.         response.Close();
  14.  
  15.     }

I am looking for good reply.


with regards,
Doni
May 22 '07 #1
Share this Question
Share on Google+
4 Replies


Plater
Expert 5K+
P: 7,872
You have two things names response, the "response" that is considered your reply to the webpage and the "response"

I would say that the credentials you are supplying are not correct, or not in correct format. I just copy and pasted your code and got no such errors
May 22 '07 #2

donilourdu
P: 53
hello friend. Now I can able to list By making one small change


protected void subFtp(string path,string uname,string pwd,string dname)
{
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create(path);// Code changes here
req.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
req.Credentials = new NetworkCredential(uname, pwd,dname);
FtpWebResponse response = (FtpWebResponse)req.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
response.StatusDescription);
Response.Write(reader.ReadToEnd());
reader.Close();
response.Close();

}


with regards,
Doni

You have two things names response, the "response" that is considered your reply to the webpage and the "response"

I would say that the credentials you are supplying are not correct, or not in correct format. I just copy and pasted your code and got no such errors
May 31 '07 #3

P: n/a
There is no way that could have been the fix. The create method is a static method on WebRequest. All you did was change the class from which the static method was accessed; the actual method remained the same.

Plater is probably right, it was probably a credentials problem. You may have retyped the credentials while troubleshooting and corrected the problem by doing so.
Nov 17 '10 #4

P: 1
I realize this is an old thread but I haven't seen any solutions posted for it as of yet.

I have had the same issue in one of my programs using almost exactly the same algorithm in an environment that repeatedly calls the method to the same ftp site. My solution was to define a ConnectionGroup on the FtpWebRequest object after defining it, and then using the ServicePoint.CloseConnectionGroup method after closing the streams at the end.

reqFTP = (FtpWebRequest)FtpWebRequest.Create(new
Uri("ftp://" + HostName + "/" + fileName));

reqFTP.ConnectionGroupName = "myConnectionGroup";
// set up other properties on the reqFTP object
// get the file from the server
// close the streams
reqFTP.ServicePoint.CloseConnectionGroup
("myConnectionGroup");

Hope this helps
Apr 1 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.