HTTP Compression Problem
Some users report that if they configure HTTP Compression in IIS, they find errors while sending generated files to client browsers.
Explanation
We use "Content-disposition", "inline; filename=test.xls" header to force the browser to open the file and "Content-disposition", "attachment; filename=test.xls" header to force the browser to open the Save As dialog and use Microsoft Excel to open the file. However, there are some exceptions that do exist.
Exceptions
Microsoft has a problem with IE 6.0 that they never fixed. IE 6.0 sometimes doesn't follow these headers (discussed above). You may have some problem with these headers if you are using IIS or some third party HTTP Compression utilities.
You can use the following code to verify that it is NOT a bug of Aspose.
[C#]
FileStream fs1 = new FileStream("d:\\invoice.xls", FileMode.Open, FileAccess.Read);
byte[] data1 = new byte[fs1.Length];
fs1.Read(data1, 0, data1.Length);
this.Response.ContentType = "application/xls";
Response.AddHeader( "content-disposition","inline; filename=book1.xls");
Response.BinaryWrite(data1);
Response.End();
[VB.NET]
Dim fs1 As FileStream = New FileStream("d:\invoice.xls",FileMode.Open,FileAccess.Read)
Dim data1() As Byte = New Byte(fs1.Length) {}
fs1.Read(data1, 0, data1.Length)
Me.Response.ContentType = "application/xls"
Response.AddHeader("content-disposition","inline; filename=book1.xls")
Response.BinaryWrite(data1)
Response.End()
Solutions
You can use one of the following workarounds to solve this problem:
- Move those specified ASP.NET files (which contain code calling Aspose.Cells) to another folder, which is not compressed.
- Disable HTTP Compression for dynamic content.
- Save the generated file in your server and provide a link to your users.
If you do wish to use HTTP Compression, please always use OpenInExcel option instead of OpenInBrowser option when you know you've enabled IIS compression.