Json – Configuring IIS dynamic compression of Json

asp.netasp.net-web-apiiisiis-8json

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?

Best Answer

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