0

I use HTTP Module to compress Requests, this is my implementation:

void context_Begin(object sender, EventArgs e)
{
  HttpApplication app = (HttpApplication)sender;
  string encoding = app.Request.Headers.Get("Accept-Encoding");
  if (encoding == null)
     return;
  Stream baseStream = app.Response.Filter;
  if (encoding.Contains("gzip"))
  {
    app.Response.Filter = new GZipStream(baseStream, CompressionMode.Compress);
    app.Response.AppendHeader("Content-Encoding", "gzip");
  }
  else if (encoding.Contains("deflate"))
  {
    app.Response.Filter = new DeflateStream(baseStream, CompressionMode.Compress);
    app.Response.AppendHeader("Content-Encoding", "deflate");
  }
 }

So every thing is fine at all, just a weird behavior with main url:

All Pages worked perfectly except main URL, my main url is: www.mynewsite.com, if I disable HTTP Module every thing is fine but when enable it I get the 404 error with main url: The resource can not be found.

I don't understand? what is the relation between this page and Request Compression?

Does any one have any idea about this? any suggestion?

Saeid
  • 13,224
  • 32
  • 107
  • 173
  • Out of curiosity, why don't you just enable IIS GZIP compression? – Lloyd Feb 25 '13 at 12:21
  • @Lloyd That cause another problem that is all characters of the page changed, and I don't know why. – Saeid Feb 25 '13 at 12:40
  • I wrote a compressor a while ago you could try and follow - http://www.lloydkinsella.net/articles/compressing-your-aspnet-web-pages-and-web-services/ – Lloyd Feb 25 '13 at 12:42

0 Answers0