简体   繁体   中英

Configuring IIS dynamic compression of Json

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: 在此输入图像描述

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. 在此输入图像描述

Any ideas?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM