Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

588
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda