【问题标题】:Configuring IIS dynamic compression of Json配置Json的IIS动态压缩
【发布时间】:2014-11-11 06:10:11
【问题描述】:

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

我正在恢复 Json,但它没有被压缩。

我已经按照How can I get gzip compression in IIS7 working?中IIS8中Json动态压缩配置的步骤@

作为:

 <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>

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

您可以在我的提琴手跟踪中看到它似乎确实是一个匹配类型,尽管它说在 FailedRequestTrace 输出中不是这种情况。

有什么想法吗?

【问题讨论】:

    标签: asp.net json iis asp.net-web-api iis-8


    【解决方案1】:

    您可以查看我的以下博客文章,了解在 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

    【讨论】:

    • 这对我有用,谢谢。但是,我对设置的存储位置感到困惑。 MMC 管理单元的底部显示配置:ApplicationHost.config。我在 C:\Windows\System32\inetsrv\config\applicationhost.config 中看不到这些设置。 (这是我之前尝试编辑的那个)。而且我在我的服务器上看不到任何其他修改过的 applicationhost.configs? (Windows 2012)
    • 我个人更喜欢使用上面第一个链接中提到的非 IIS 压缩方式。您是否尝试过这种方式,因为它更简单并提供更多控制权..
    • 这个特定的应用程序是一个 webforms 应用程序,我们目前没有添加 WebAPI 的能力。大多数这些调用都是针对 web 表单上的 Webmethods 的。但是,我肯定会查看上述链接以了解我正在研究的其他 MVC/WebAPI 项目。
    猜你喜欢
    • 1970-01-01
    • 2018-09-17
    • 2016-01-02
    • 1970-01-01
    • 2015-01-23
    • 2019-12-26
    • 1970-01-01
    • 1970-01-01
    • 2012-07-21
    相关资源
    最近更新 更多