Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

596
Vistas
Download file to browser from SFTP server in ASP.NET using SSH.NET

With SSH.NET, I am trying to trigger a file to be downloaded by the browser instead of directly writing it to the local file storage.

using(var saveFile = File.OpenWrite(@"Downloads")) {
  result = client.BeginDownloadFile(remotePath + fileName, saveFile) as SftpUploadAsyncResult;

  client.EndUploadFile(result);
}

The above code fails as my the application pool identity doesn't have permission to write files and I cannot give permission as I don't have Admin privileges to my computer.

So better option would be to trigger the download through browser which was working earlier with FtpWebRequest.

But my current task is to convert the FTP download to SFTP download.

Can someone suggest the best way to trigger browser download?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Download the file to HttpResponse.OutputStream:

HttpResponse response = HttpContext.Current.Response;

response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);

client.DownloadFile(remotePath + fileName, response.OutputStream);
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda