Hi,
Exporting webgrid data in to excel previously working fine in my site.
But after adding gzip compression utility in my site, Exported data get damaged.
Please give me the suggestions.
Thanks in advance.
Hello,
You can use gzip settings and disable compression only of export.
Thanks.
Hi Ivan,
Thank you for reply.
but how can i disable compression only of export?
do you have any sample code?
On button click i export the grid data in excel. for e.g. UltraWebGridExcelExporter1.Export(UltraWebGrid1)
Protected Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As System.EventArgs)
Dim acceptEncoding As String = app.Request.Headers("Accept-Encoding")
If Not (TypeOf app.Context.CurrentHandler Is Page) OrElse app.Request("HTTP_X_MICROSOFTAJAX") IsNot Nothing Then
Return
End If
If acceptEncoding Is Nothing OrElse acceptEncoding.Length = 0 Then
acceptEncoding = acceptEncoding.ToLower()
If acceptEncoding.Contains("deflate") OrElse acceptEncoding = "*" Then
' defalte
app.Response.Filter = New DeflateStream(prevUncompressedStream, CompressionMode.Compress)
app.Response.AppendHeader("Content-Encoding", "deflate")
ElseIf acceptEncoding.Contains("gzip") Then
' gzip
app.Response.Filter = New GZipStream(prevUncompressedStream, CompressionMode.Compress)
app.Response.AppendHeader("Content-Encoding", "gzip")
End Sub