tags:

views:

20

answers:

1

Well, I got gzip working, but there are issues with IE. (works fine with FF and Chrome) Message: ASP.NET Ajax client-side framework failed to load. (and many other js related errors)

How can I prevent gzip compression on ie browsers ?? Other people who had similar issues enabled compression in IIS and that seems to solve the issue, but I can't do this on my discount machine...

This is what I use:

        HttpApplication app = (HttpApplication)sender;

        string acceptEncoding = app.Request.Headers["Accept-Encoding"];
        Stream prevUncompressedStream = app.Response.Filter;
        if (acceptEncoding != null && acceptEncoding.Length != 0)
        {

            acceptEncoding = acceptEncoding.ToLower();
            if (acceptEncoding.Contains("gzip"))
            {

                app.Response.Filter = new GZipStream(prevUncompressedStream, CompressionMode.Compress);
                app.Response.AppendHeader("Content-Encoding", "gzip");
            }

            else if (acceptEncoding.Contains("deflate"))
            {
                // defalte

                app.Response.Filter = new DeflateStream(prevUncompressedStream, CompressionMode.Compress);
                app.Response.AppendHeader("Content-Encoding", "deflate");

            }
        }
A: 

Try to compress GZip only the files that ends on aspx and left WebResource that contains the Javascript that you have problem, to compress by iis him self.

string cTheFile = HttpContext.Current.Request.Path;
string sExtentionOfThisFile = System.IO.Path.GetExtension(cTheFile);

if (sExtentionOfThisFile.Equals(".aspx", StringComparison.InvariantCultureIgnoreCase))
{
    // run your code for compression here
}

This will solve your problem.

Aristos
Issue solved. Thx
dll32
@dll32 the real problem when you gzip the webresource is that webresource is set the wrong content-length after compression. How ever IIS can compress them with out problem
Aristos