HTTPS SSL 问题

HTTPS/SSL 问题

一些用户报告说他们在下载由 Aspose.Cells 生成的 Excel 文件时遇到问题。当保存对话框打开时,文件名包含 aspx 页面的名称而不是 excel 文件,文件类型为空。

解释

我们更改了 HTTP 响应标头以解决 HTTP 压缩问题。这可能会导致在通过 HTTPS/SSL 将文件发送到客户端浏览器时出现问题。

解决方案

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Saves file to memory
MemoryStream stream = new MemoryStream();
excel.Save(stream, SaveFormat.Excel97To2003);
Response.ContentType = "application/vnd.ms-excel";
// This is same as OpenInExcel option
Response.AddHeader("content-disposition", "attachment; filename=book1.xls");
// This is same as OpenInBrowser option
// response.AddHeader("content-disposition", "inline; filename=book1.xls");
Response.BinaryWrite(stream.ToArray());