After implementing the RadCompression model on a previously working ashx page I was using for secure file downloads, itstopped working in Firefox, Chrome, & Safari, but continued to work in IE (tested v9). I found 2 possible places for the error, but due to time constraints had to stop and simply remove the RadCompression module.
1. On my development box, Win 7, IIS 7, flushing the data (context.Response.Flush()) between the header and the content caused the browsers listed above to report an invalid compression.
2. On my production server, Windows Server 2003, IIS 6, the browsers just sit there and spin, as if they are waiting for more content. I think this is due to my manually adding a "Content-Length" based on the size of the uncompressed content. Is there a sample showing the correct parameters to set when using RadCompression in this scenario? My page, based on parameters, may return any of the following, and so I am also setting the content type and content-disposition headers manually:
a. HTML (text/html)
b. Text (text/plain)
c. Zip (application/zip)
d. Excel (application/vnd.ms-excel)
e. Excel 2007 (application/vns.openxmlformats-officedocument.spreadsheetml.sheet)
f. Jpg (image/jpeg)
These files are dynamically generated, so I would also like to specify "no-cache" in the sample as well.
The following is my working (without RadCompression) sample. (Again, it works in IE, but not others.)
1. On my development box, Win 7, IIS 7, flushing the data (context.Response.Flush()) between the header and the content caused the browsers listed above to report an invalid compression.
2. On my production server, Windows Server 2003, IIS 6, the browsers just sit there and spin, as if they are waiting for more content. I think this is due to my manually adding a "Content-Length" based on the size of the uncompressed content. Is there a sample showing the correct parameters to set when using RadCompression in this scenario? My page, based on parameters, may return any of the following, and so I am also setting the content type and content-disposition headers manually:
a. HTML (text/html)
b. Text (text/plain)
c. Zip (application/zip)
d. Excel (application/vnd.ms-excel)
e. Excel 2007 (application/vns.openxmlformats-officedocument.spreadsheetml.sheet)
f. Jpg (image/jpeg)
These files are dynamically generated, so I would also like to specify "no-cache" in the sample as well.
The following is my working (without RadCompression) sample. (Again, it works in IE, but not others.)
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest '''The following 2 lines do not seem to make a difference, but were added when trying to test context.Response.Clear context.Response.BufferOutput = True 'Get the filename Dim fileName As String = context.Request.QueryString("i") 'Get the file type Dim fileType As String = context.Request.QueryString("t") 'Get the project name Dim projectName As String = Managers.SessionManager.ProjectName(context.Session) 'Get the userId Dim userId As Integer = Managers.SessionManager.UserId(context.Session) 'Make sure the project and user name are valid If IsProjectAndUserValid(projectName, userId) = True Then Dim securePath As String = Utilities.IO.GetSecureDirectory(Managers.ConfigManager.SecureOutput, projectName, userId) 'Create the full physical path to the file Dim fullPath As String = IO.Path.Combine(securePath, fileName) 'See if the file exist If IO.File.Exists(fullPath) Then 'Open a fileinfo object for the file Dim currentFileInfo As New IO.FileInfo(fullPath) Select Case fileType.ToLower Case "zip" context.Response.AddHeader("Content-Disposition", "attachment;filename=MyZip.zip") context.Response.ContentType = "application/zip" Case "export" 'Get the fileextension Dim fileExtension As String = IO.Path.GetExtension(fullPath) If fileExtension = ".html" OrElse fileExtension = ".htm" Then context.Response.AddHeader("Content-Disposition", "attachment;filename=Export.htm") context.Response.ContentType = "text/html" ElseIf fileExtension = ".txt" Then context.Response.AddHeader("Content-Disposition", "attachment;filename=Export.txt") context.Response.ContentType = "text/plain" ElseIf fileExtension = ".xls" Then context.Response.AddHeader("Content-Disposition", "attachment;filename=Export.xls") context.Response.ContentType = "application/vnd.ms-excel" ElseIf fileExtension = ".xlsx" Then context.Response.AddHeader("Content-Disposition", "attachment;filename=Export.xlsx") context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" End If Case "print" context.Response.ContentType = "text/html" Case "image" context.Response.AddHeader("Content-Disposition", "inline;filename=Print.jpg") context.Response.ContentType = "image/jpeg" End Select '''The following line has had inconsistant results in some browsers 'context.Response.CacheControl = "no-cache" '''Is the following line is another (unconfirmed) problem for RadCompression? context.Response.AddHeader("Content-Length", currentFileInfo.Length.ToString) context.Response.StatusCode = 200 ''''The following line breaks RadCompression in IIS7 'context.Flush() context.Response.WriteFile(fullPath) context.Response.Flush() context.Response.End() Else context.Response.StatusCode = 200 context.Response.Write("No data located for this request.") context.Response.End() End If End If End Sub