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

167
Vistas
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 Respuestas
Responde la pregunta

0

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

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