title: Return File equivalent in Web Forms
body: <p>I have the following code in my MVC C# application:</p>
  
  <pre><code>      return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "PSL.xlsx"); 
  </code></pre>
  
  <p>which returns a PSL file from a stream. I am trying to do the same thing in my Web Forms code behind with:</p>
  
  <pre><code>            Response.Clear();
              Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
              Response.AddHeader("Content-Disposition", "attachment; filename=PSL.xlsx");
              Response.BinaryWrite(stream.ToArray());
              // myMemoryStream.WriteTo(Response.OutputStream); //works too
              Response.Flush();
              Response.Close();
              Response.End();
  </code></pre>
  
  <p>Wanted to know if this is the right approach as I am getting the following error message:</p>
  
  <pre><code>  Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
  </code></pre>