ftp - C# FtpWebRequest - special character "§" in password -


i have got problem using ftpwebrequest special character "§" in password. code looks this:

ftpwebrequest reqftp = (ftpwebrequest)ftpwebrequest.create(new uri("ftp://ftphost")); reqftp.method = webrequestmethods.ftp.listdirectory; reqftp.usepassive = true; reqftp.enablessl = false; reqftp.timeout = 60000; reqftp.usebinary = false; reqftp.credentials = new networkcredential("user", "pa§");  ftpwebresponse response = (ftpwebresponse)reqftp.getresponse(); 

the getresponse()-method fails "530 user cannot log in". filezilla login works.

i traced network traffic wireshark , noticed following:

  • filezilla converts password "pa\302\247", tries log in , fails. after filezilla retries connecting password "pa\247" succeeds.
  • the ftpwebrequest converts password "pa\302\247", tries log in , fails , throws exception.

how can force ftpwebrequest convert password "pa\247" , not "pa\302\247"?

thank you.

this appears encoding problem. § character \302\247 in utf-8 , \247 in iso-8859-1. based on information provided tells me request being sent charset utf-8 , server expecting iso-8859-1. you've got 2 choices, if have access ftp server should able change default char set. otherwise you'll need send ftp request charset iso-8859-1. don't have time test can give following code shot (notice added header):

ftpwebrequest reqftp = (ftpwebrequest)ftpwebrequest.create(new uri("ftp://ftphost")); reqftp.method = webrequestmethods.ftp.listdirectory; reqftp.usepassive = true; reqftp.enablessl = false; reqftp.timeout = 60000; reqftp.usebinary = false; reqftp.credentials = new networkcredential("user", "pa§"); reqftp.headers.add(httprequestheader.contenttype, "text/plain; charset=\"iso-8859-1\"");  ftpwebresponse response = (ftpwebresponse)reqftp.getresponse(); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -