c# - FtpWebRequest Upload on Active mode with SSL returns error 501 -


here's current code:

    public bool processfile(string filename, string filenameandpath)     {         string address = string.format("ftp://{0}/{1}", _address, filename);         servicepointmanager.servercertificatevalidationcallback = new remotecertificatevalidationcallback(onvalidatecertificate);         servicepointmanager.expect100continue = true;         ftpwebrequest request = (ftpwebrequest) webrequest.create(address);         request.method = webrequestmethods.ftp.uploadfile;         request.enablessl = true;         request.usebinary = false;         request.usepassive = false;         request.credentials = new networkcredential(_username, _password);         if (!file.exists(filenameandpath))         {             log(string.format("{0}error - locating file migrate. path - {1}", environment.newline, filenameandpath));             return false;         }         try         {             streamreader filein = new streamreader(filenameandpath);             byte[] filecontents = encoding.utf8.getbytes(filein.readtoend());             filein.close();             request.contentlength = filecontents.length;              stream requeststream = request.getrequeststream();             requeststream.write(filecontents, 0, filecontents.length);             requeststream.close();              ftpwebresponse response = (ftpwebresponse)request.getresponse();             log(string.format("{0}file - {1} uploaded. response status: {2}", environment.newline, filenameandpath, response.statusdescription));             response.close();             return true;         }         catch (exception ex)         {             log(string.format("{0}error - upload routine. file - {1}. error exception: {2}", environment.newline, filenameandpath, util.getfullerror(ex)));             return false;         }     } 

assume port(21) supplied address (host:21) , credentials valid. getting exception on getrequeststream follows :

the remote server returned error: (501) syntax error in parameters or arguments.

i can't seem figure out problem. have checked everything. yes, need use active mode - not able passive. yes, uses ssl/tls. should work doesn't , missing here.

need hints or guidance on going wrong here.

after enabling stack tracing determined error missing port. put guy messed , failed set active move our ftp. because port assigned returned in initial connection , not working, ftp server rejected invalid , .net library interpreted server error message. there nothing wrong code.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -