Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!