你想要像这样指定content-type
和content-dispisition
标题 - Response.ContentType ="application/vnd.ms-excel"在IE和Firefox中工作但在Safari中不起作用,然后流式传输你的文件.完成后,调用Response.End()
以停止应用程序执行
代码示例:
void StreamExcelFile(byte[] bytes)
{
Response.Clear();
Response.ContentType = "application/force-download";
Response.AddHeader("content-disposition", "attachment; filename=name_you_file.xls");
Response.BinaryWrite(bytes);
Response.End();
}
Run Code Online (Sandbox Code Playgroud)