配置Json的IIS动态压缩

Tim*_*Tim 3 asp.net iis json asp.net-web-api iis-8

我在测试Json输出的dynamicCompression时遇到问题.Application是一个MVC/WEBAPI5应用程序,我正在调查的请求是Get WebAPI请求.

我让Json回来但没有被压缩.

我已经按照步骤在IIS8中配置Json的动态压缩了如何在IIS7中运行gzip压缩?

如:

 <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>
Run Code Online (Sandbox Code Playgroud)

我安装了压缩模块,我可以在FailedRequestTracelog中看到以下特定调用的以下内容: 在此输入图像描述

您可以在我的fiddler跟踪中看到它看起来似乎是一个匹配的类型,尽管它说FailedRequestTrace输出中不是这种情况. 在此输入图像描述

有任何想法吗?

Kir*_*lla 7

您可以在Web API中查看我在下面的博客文章中进行压缩的一种方法. http://blogs.msdn.com/b/kiranchalla/archive/2012/09/04/handling-compression-accept-encoding-sample.aspx

如果您想使用IIS进行压缩,请查看以下帖子:https: //stackoverflow.com/a/17331627/1184056