about ftp download method

Last Reply 2 days ago By dharmendr

Posted 12 days ago

hi

I am using ftp download method on asp.net mvc project , its working if file less than 50 MB otherwise return like timeout , so the download method not respond long time , I think I need to change download method , its like below

            var request = (FtpWebRequest)WebRequest.Create(adres + Filename);
            request.Method = WebRequestMethods.Ftp.DownloadFile;
            //request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
            request.Credentials = new NetworkCredential(FtpUser, FtpPwd);
            request.UsePassive = true;
            request.UseBinary = true;
            request.EnableSsl = false;

            var response = (FtpWebResponse)request.GetResponse();
            using (var stream = new MemoryStream())
            {
                response.GetResponseStream().CopyTo(stream);
                Response.AddHeader("content-disposition", "attachment;filename=" + Path.GetFileName(adres + Filename));
                //Response.ContentType = "application/zip";
                Response.ContentType = "application/force-download";
                Response.AddHeader("Content-Length", stream.Length.ToString(CultureInfo.InvariantCulture));
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(stream.ToArray());
            }
            response.Close();
            Response.Close();

 

You are viewing reply posted by: pandeyism 4 days ago.
Posted 4 days ago

Hi alya14,

Share your updated code with us.