I created a ASP.Net application in which I am uploading a file on a FTP SERVER.
Its works fine when I am running it from CASINI server (ASP.Net Server). But when hosted in IIS it is giving following error:
The remote name could not be resolved: 'ftp.ServerName' at System.Net.FtpWebRequest.GetRequestStream()
webEx.Response - > System.Net.FtpWebResponse
webEx.Status - > NameResolutionFailure
webEx.Message - > The remote name could not be resolved: 'ftp.ServerName'
On changing the server name with its IP address, following error comes:
Unable to connect to the remote server at System.Net.FtpWebRequest.GetRequestStream()
webEx.Response - > System.Net.FtpWebResponse
webEx.Status - > ConnectFailure
webEx.Message - > Unable to connect to the remote server
Note: We are already using the Microsoft Firewall Client for ISA Server.
Code Snippet:
Uri serverUri = new Uri(ftpPath + ftpFileName);
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(serverUri);
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Proxy = null;
FileStream stream = File.OpenRead(fileName);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
Stream reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
P.S: I am reposting it here... earlier i posted it under following category..
Home › Forums › IIS 5.x & 6.0 › ASP.NET Administration › FileUpload problem on a FTP server