Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All

I am trying to upload a file on clients server using the FtpWebRequest but There is firewall on clients machine which creating problem the code which I used is bellow
// for creating ftp connection
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(ConfigurationManager.AppSettings["ftppath"].ToString() + filename);

            // to tell that going to upload file
            request.Method = WebRequestMethods.Ftp.UploadFile;
            // settng the network credentials
            request.Credentials = new NetworkCredential("" + ConfigurationManager.AppSettings["ftpuser"].ToString() + "", "" + ConfigurationManager.AppSettings["ftppass"].ToString() + "");
            // setting passive mode
            request.UsePassive = true;
            request.UseBinary = true;
            request.KeepAlive = false;
            //request.EnableSsl = true;
            
            // reading file from server which is going to upload
            FileStream stream = File.OpenRead(Server.MapPath(csvpath + filename));
            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            // this line is giving me error since the connection is changed by the NAT firewall due to this I am 
            // getting error 
            // thi line is for uploading the file
            Stream reqStream = request.GetRequestStream();
            reqStream.Write(buffer, 0, buffer.Length);
            reqStream.Close();

the error which I am getting is

"The server returned an address in response to the PASV command that is different than the address"

If any body have any idea about this please help me

Thanks
Posted

1 solution

Solution[^] is here.
 
Share this answer
 
Comments
Indresh1210 1-Mar-11 3:45am    
Hi I all ready had gone through the link which you send but it is still not solved

Anyway thanks for you response

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900