title: ASP.NET: XLSX file is being corrupted in Response
body: <p>When opening the XLSX file after downloading, I get the error message in Excel:</p>
  
  <blockquote>
    <p>We found a problem with some content in '<em>filename.xlsx</em>'. Do you want us to try to recover as much as we can?  If you trust the source of this workbook, click Yes.</p>
  </blockquote>
  
  <p>When I check file on the server, I don't get any errors in Excel.  </p>
  
  <p>I'm using ASP.NET to send the file to the user as shown below:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e) 
  {
      Response.Clear();
      Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      Response.AppendHeader("Content-Disposition", "Attachment; filename=\"filename.xlsx\"");
      Response.AppendHeader("Content-Length", File.ReadAllBytes(xlsxFilepath).Length);
      Response.TransmitFile(xlsxFilepath);
      Response.End();
  }
  </code></pre>
  
  <p>This issue only started happening when I changed servers.</p>