I have the following code in my MVC C# application:
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "PSL.xlsx");
which returns a PSL file from a stream. I am trying to do the same thing in my Web Forms code behind with:
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();
Wanted to know if this is the right approach as I am getting the following error message:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}