Reputation: 2750
I need to compress my WCF response. After few google search, I found that
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??
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.
Upvotes: 1
Views: 526
Reputation: 63956
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.
Upvotes: 1