3

I'm having problems testing the dynamicCompression of my Json output. The Application is an MVC/WEBAPI5 application and the request I'm investigating is a Get WebAPI request.

Im getting Json back but its not being compressed.

I've followed the steps to configure dynamic compression of Json in IIS8 in How can I get gzip compression in IIS7 working?

as :

 <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/json" enabled="true" />
            <add mimeType="application/json; charset=utf-8" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/atom+xml" enabled="true" />
            <add mimeType="application/xaml+xml" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

I have the compression module installed and i can see the following in the FailedRequestTracelog for this particular call: enter image description here

You can see in my fiddler trace that it does seem to be a matching type despite it saying this is not the case in the FailedRequestTrace output. enter image description here

Any ideas?

Community
  • 1
  • 1
Tim
  • 7,401
  • 13
  • 61
  • 102

1 Answers1

9

You can take a look at my below blog post on one way of doing compression in Web API. http://blogs.msdn.com/b/kiranchalla/archive/2012/09/04/handling-compression-accept-encoding-sample.aspx

If you would like to use IIS for compression, take a look at the following post: https://stackoverflow.com/a/17331627/1184056

Community
  • 1
  • 1
Kiran
  • 56,921
  • 15
  • 176
  • 161
  • This works for me thanks. However I'm confused as to where the settings are stored. The bottom of the MMC snapin says Configuration: ApplicationHost.config. I cannot see these settings in the C:\Windows\System32\inetsrv\config\applicationhost.config. (which is the one i tried to edit before). And I cannot see any other modified applicationhost.configs on my server? (Windows 2012) – Tim Sep 18 '14 at 05:45
  • I personally prefer doing the non-IIS way of compression as mentioned in the first link above. Did you try that way as its simpler and provides your more control.. – Kiran Sep 18 '14 at 06:22
  • 1
    This particular application is a webforms application we don't currently have the ability to add WebAPI. Most of these calls are to Webmethods on webforms. However ill certainly look into the above link for other MVC/WebAPI projects im looking into. – Tim Sep 18 '14 at 06:34