Page view counter

Compression does not work with UpdatePanel 2

Last post 10-21-2008 8:00 AM by zhornykUN. 2 replies.

Sort Posts:

  • Compression does not work with UpdatePanel 2

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

    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
  • Re: Compression does not work with UpdatePanel 2

    10-21-2008, 7:18 AM
    • Loading...
    • d.marzo
    • Joined on 10-21-2008, 11:11 AM
    • Posts 1
    • Points 2

    This is a bug (nasty), compress update panel response its high performance improvement,
    reported at Microsoft Connect: https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=357565

     Expected to be fixed at 3.5.

    But... Too much people work with 2.0 (include us), and dont want compress at IIS level.

    We play for a while and try to find a workaround, we found, but we need feedback and advice.

    You could see description at:

     https://connect.microsoft.com/VisualStudio/feedback/Workaround.aspx?FeedbackID=357565

    And download source code:

    http://www.solnatec.com/archive/public/2008/CompressAjaxResponse.zip

    Thanks in advance.

    David Marzo
    www.solnatec.com

     

  • Re: Compression does not work with UpdatePanel 2

    10-21-2008, 8:00 AM
    • Loading...
    • zhornykUN
    • Joined on 03-28-2008, 8:31 PM
    • Posts 8
    • Points 4
    Thank you for response but I decided not to use UpdatePanel in my solution due to this and others issues.
Page 1 of 1 (3 items)