MbCompression and Ionic Libraries working together

May 1, 2009 at 5:34 PM
Hi.

I'm using MbCompression on my application developed with ASP.NET 2.0, and the compression work fine.
The application need to use Ionic library to generate zip files.
Compression alone works fine, and zip files generation alone works fine too (without page compression), but when turn on MbCompression the zip file generated is not valid.
I think that i need to use exclude keys on the web.config, but i don´t how. I exclude that page what generate zip file, but i obtain the same results.
This is the page code:

 

 

 

 

Imports

 

Ionic.Zip

 

Partial Class Pruebas_Default4
        Inherits UI.Page

 

 

 

Protected Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.ClickTry

 

 

'get data from database
Dim name As String = ""
Dim dt As System.Data.DataTable = Nothing
Dim obj As New clsSysFields(1, 1)
obj.funGetData(dt)
Dim str As New StringBuilder()
For i As Integer = 0 To dt.Rows.Count - 1
    For j As Integer = 2 To dt.Columns.Count - 1
        name = dt.Rows(i).Item(j).ToString +
" "
        str.Append(name.Substring(0, 20))
    Next
    str.AppendLine()
Next

 

 

Dim archiveName As String = String.Format("archive-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd"))
Response.Clear()
Response.ContentType =
"application/zip"
Response.AddHeader("content-disposition", "filename=" + archiveName)
Using zip As ZipFile = New ZipFile
    zip.AddFileFromString(
"Readme.txt", "", str.ToString())
    zip.Save(Response.OutputStream)
End Using
Response.End()

Catch
ex As System.Threading.ThreadAbortException
Catch ex As Exception
    Throw
End Try
End Sub
End Class

 

This is the web.config (lines referred to MbCompression only):

<

 

sectionGroup name="Miron.web">
    <
section name="CompressorSettings" type="Miron.Web.MbCompression.SettingsConfigSection" />
</
sectionGroup>

 

<

 

httpHandlers>
    <
remove path="*.asmx" verb="*"/>
    <
add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    <
add path="*.thumb" verb="*" type="thumbnailer" validate="false"/>
    <
add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,     PublicKeyToken=31bf3856ad364e35"     validate="false"/>
    <
add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"     validate="false"/>
    <!--Compresion HTTP-->
    <
add verb="*" path="jslib.axd" type="Miron.Web.MbCompression.JavaScriptCompressionHandler, MbCompression" validate="false"/>
    <
add verb="*" path="css.axd" type="Miron.Web.MbCompression.CssCompressionHandler, MbCompression" validate="false"/>
    <!--
Compresion HTTP-->
</
httpHandlers>

 

 

<

 

httpModules>
    <
add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <!--
Compresion HTTP-->
    <
add name="MbCompressionModule" type="Miron.Web.MbCompression.MbCompressionModule, MbCompression"/>
    <
add name="WebResourceCompressionModule" type="Miron.Web.MbCompression.WebResourceCompressionModule, MbCompression"/>
    <!--
Compresion HTTP-->
</httpModules>

 

<

 

Miron.web>
    
<CompressorSettings compressCSS="true" compressJavaScript="true" compressPage="true" compressWebResource="true" minifyContent="true" cachingStorage="OutputCache"
    autoMode="true" scriptsVersion="1.2" cssVersion="1.2">
    <
excludePaths>
        <
add key="~/Default6.aspx" />
    </excludePaths>
    </
CompressorSettings>
</
Miron.web>

 

Default6.aspx included on excludePaths key is zip file generate page.

Than you, and i wait your help.
Coordinator
Sep 23, 2009 at 6:35 PM

See instructions in the readme.txt file in the latest source code