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

169
Visualizações
Download zip is invalid

I have a simple aspx page where is in the codebehind I am creating a zip file and streaming it back. Everything worked fine while I kept all my code inside of page_load method. Now I am executing the code on a button click. After download Windows cannot open the zip saying it is invalid. Here is my code:

<body style="height: 100%; overflow: hidden" onload="return onBodyLoad();">
<script>
    function onBodyLoad() {
        document.getElementById("ExportBtn").click();
    }
</script>

protected void ExportBtn_OnClick(object sender, EventArgs e)
{
   // prepare zip
   .....
   // send zip back
   Response.Clear();
   Response.AppendHeader("content-disposition", "attachment; filename=" + fileToDownload);
   Response.ContentType = "application/zip";
   Response.BinaryWrite(File.ReadAllBytes(zipPath));
}

The same code wihtout a button click runs fine from the page_load which currently looks like this:

protected void Page_Load(object sender, EventArgs e)
{
    
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Found the problem. All I needed is Response.End(); as the last statement.

about 4 years ago · Juan Pablo Isaza 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