title: ASP.NET How To Stream File To User
body: <p>Initially I was trying to figure out what the difference is between Response.Close and Response.End, but after doing more googling and research, its clear that I haven't seen a common way a Byte[] gets sent back to the client.  I'll leave the code sample below, but I would like to know what the industry standard is for doing this.</p>
  
  <pre><code>Byte[] myBytes = GetReportBytes();
  HttpContext.Current.Response.ClearContent();
  HttpContext.Current.Response.AppendHeader("content-length", myBytes.Length.ToString());
  HttpContext.Current.Response.AppendHeader("content-Disposition", "attachment;filename=" + this.ReportFileName + GetReportExtension());
  HttpContext.Current.Response.ContentType = GetApplicationContentType();
  HttpContext.Current.Response.BinaryWrite(myBytes);
  HttpContext.Current.Response.Flush();
  HttpContext.Current.Response.Close();
  //CERT FIX
  //HttpContext.Current.Response.End();
  </code></pre>