1

I need to compress my WCF response. After few google search, I found that

  • I need to enable compression on iis7
  • I need to add some entry in the applicationhost.config.

My wcf is hosted on discountasp.net. In the control panel, I didn't find any option to enable compression. And also, the applicationhost.config is located in the 'C:\Windows\System32\Inetsrv\Config\applicationHost.config' directory.

And in the shared hosting environment, I dont have access to this directory.

My question is, if my above observation is correct, how do I get it done in the shared hosting??

edit:

I have found something here: enter link description here

I tried this with no luck. In the response header in Fiddler, I dont see any compression.

Reza.Hoque
  • 2,690
  • 10
  • 49
  • 78

1 Answers1

1

One alternative is to implement an HttpModule that would intercept the response based on the content type and compress the output on the fly, using the GZipStream class.

This post has a complete example and I've used this method successfully in production. All you need to do is change your Web.config to register the http module:

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

The example does it for JSON responses but there's nothing that stops you from doing the same thing for XML responses.

Icarus
  • 63,293
  • 14
  • 100
  • 115
  • Thanks for the reply. if I add the in my web.config, I get error. HTTP Error 500.22 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. – Reza.Hoque Aug 07 '12 at 08:55
  • Hi, have you solve your issue? Please try to change your application pool to classic mode. If it doesnt solve your issue, please try to contact their support team. :) –  Sep 03 '12 at 13:25