Compression does not work with UpdatePanel 2

Last post 08-21-2007 6:03 PM by zhornyk. 0 replies.

Sort Posts:

  • Compression does not work with UpdatePanel 2

    08-21-2007, 6:03 PM
    • Loading...
    • zhornyk
    • Joined on 05-21-2007, 1:54 AM
    • Posts 10

    Hi

    I'm using HttpModule for comression (GZipStream) . It works fine but there is strange error after async request from UpdatePanel : "The message received from the server control could not be parsed....."

    After debugging Web.Extensions' javascript (clientside AJAX) I've found that sometimes decompressed response from server does not contain one or several last symbols. So clientside AJAX cannot parse it.

    Here you can read that this is known issue with GZIp and UpdatePanel:

    http://www.thescripts.com/forum/thread670482.html
     
    But I cannot believe that MS may commit such awful bug.
     
    Maybe I'm doing something incorrect on serverside?
     
    I really don't want to change Web.Extensions manually and recompile it to add missing symbols...
     
    Here is my server code:
     
     
    <httpModules>

    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    <add name="CompressionModule" type="WebSite.CompressionModule" />

    </httpModules>

    #region Using

    using System;

    using System.Web;

    using System.IO;

    using System.IO.Compression;

    #endregion

     

    namespace
    WebSite

    {

    /// <summary>

    /// Compresses the output using standard gzip/deflate.

    /// </summary>

    public class CompressionModule : IHttpModule

    {

     

    public void Init(HttpApplication context)

    {

    context.BeginRequest +=
    new EventHandler(context_BeginRequest);

    }

    private void context_BeginRequest(object sender, EventArgs e)

    {

    HttpApplication app = (HttpApplication)sender;

    if (app.Request.Url.ToString().ToLower().IndexOf("aspx") < 0) return;

    string encodings = app.Request.Headers.Get("Accept-Encoding");

    if (encodings == null) return;Stream baseStream = app.Response.Filter;

    encodings = encodings.ToLower();

    if (encodings.Contains("gzip"))

    {

    app.Response.Filter =
    new GZipStream(baseStream,

    CompressionMode.Compress);

    app.Response.AppendHeader(
    "Content-Encoding", "gzip");

    }

    else if (encodings.Contains("deflate"))

    {

    app.Response.Filter =
    new DeflateStream(baseStream,

    CompressionMode.Compress);

    app.Response.AppendHeader(
    "Content-Encoding", "deflate");

    }

    }

    public void Dispose()

    {

    }

    } 

     
    Please help me.
    Andriy Zhornyk
    http://www.jetideas.com
Page 1 of 1 (1 items)
Microsoft Communities
Page view counter