HTTP Compression with AJAX
June 20th, 2007I read HTTP compression in ASP.NET 2.0 by Mads Kristensen the other day and tried it out on a website that is using ASP.NET AJAX. I found that while the development web server run by Visual Studio handles it all just fine, IIS 6 on the server does not. Somehow the process is corrupting the page state. So while I want to use the compression to get what I can for bandwidth savings I had to work around this problem.
What I did was check for the ViewState data on a request and if it was there I would not add the compression filter to the request. The initial page load will still be compressed but any PostBacks or AJAX callbacks will not. I can live with that for now. Below is the code snippet. You can get the full source on Kristensen's website.
On my website I was able to take a 50KB page down to 13KB.

June 27th, 2007 at 5:49 am
Hello,
When you use Ajax, usually stream lost last symbol.
I'm use Anthem.Net.
These lines of code in javascript solved my problems:
if (responseText.substr(responseText.length-1,1)=="]")
responseText+="}";
else if (responseText.substr(responseText.length-2,2)!="}}")
responseText+="}";
June 28th, 2007 at 5:12 am
Hello Sergey ,
Please give more details on your code.
I mean where did you add/modify code in follwing part of js?
if (responseText.substr(responseText.length-1,1)=="]")
responseText+="}";
else if (responseText.substr(responseText.length-2,2)!="}}")
responseText+="}";
where is this javascript ??
Thank you very much.
Kiran
August 21st, 2007 at 4:28 pm
[...] this is known issue with GZIp and UpdatePanel: http://www.thescripts.com/forum/thread670482.html http://brennan.offwhite.net/blog/2007/06/20/http-compression-with-ajax But I cannot believe that MS may commit such awful bug. Maybe I'm doing something [...]