title: asp.net large file download out of memory exception
body: <p>I'm trying to download a file with size greater than 50mb in an asp.net page. But it fails on our production server. It works on development and QA servers. I'm using the following code.</p>
  
  <pre><code>Response.Clear()
  oBinaryReader = New System.IO.BinaryReader(System.IO.File.OpenRead(sDocPath))
  lFileSize = Microsoft.VisualBasic.FileLen(sDocPath)
  Response.AddHeader("Content-Disposition", "attachment;filename=" &amp; sDownloadFileName)
  Response.ContentType = "application/unknown"
  Response.BinaryWrite(oBinaryReader.ReadBytes(lFileSize))
  Response.Flush()
  HttpContext.Current.ApplicationInstance.CompleteRequest()
  Response.End()
  </code></pre>
  
  <p>The error I'm getting from the server is as below.</p>
  
  <p>Page_Load <strong>System.OutOfMemoryException</strong>: Exception of type '<code>System.OutOfMemoryException</code>' was thrown.
  at System.IO.BinaryReader.ReadBytes(Int32 count)
  at ExportDoc.Page_Load(Object sender, EventArgs e) in c:\sitename\ExportDoc.aspx.vb:line 87 Server Name </p>
  
  <p>What is wrong with the code?</p>