So I have a controller method that creates an excel package and sends the response back to the user to save/download. The problem that I am having is that the response is not prompting the Open/Save dialog from appearing. Is there something I am missing?
[HttpPost]
public ActionResult Export()
{
var excel = do stuff to create open XML package
using (var memoryStream = new MemoryStream())
{
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AddHeader("content-disposition", "attachment; filename=" + Convert.ToString(fileName).Replace(" ", "_") + ".xlsx");
excel.SaveAs(memoryStream);
memoryStream.WriteTo(Response.OutputStream);
Response.BinaryWrite(excel.GetAsByteArray());
Response.Flush();
Response.End();
}
return null