IIS 7.5没有COM pressing JSON当应用程序的web.config设置应用程序、COM、IIS、pressing

2023-09-05 00:20:54 作者:╚端木良纪

我一直在努力使JSON COM pression从我们的MVC3网站之一。从各种文章我读过它好像我应该能够设置应用程序/ JSON;字符集= UTF-8 MIME类型的应用程序的web.config文件。但这样做并没有启用COM pression。但是,当添加到ApplicationHost.config文件,它的工作原理。我失去了一些东西呢?

I've been working on enabling JSON compression from one of our MVC3 sites. From various articles I've read it seems as though I should be able to set the application/json; charset=utf-8 MIME type in the applications web.config file. But doing so does not enable compression. But when added to the applicationhost.config file, it works. Am I missing something here?

我的应用程序的web.config有以下添加进去:

My application web.config has the following added to it:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
    <dynamicTypes>
        <add mimeType="application/javascript; charset=utf-8" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/json; charset=utf-8" enabled="true" />
    </dynamicTypes>
    <staticTypes>
        <add mimeType="application/javascript; charset=utf-8" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/json; charset=utf-8" enabled="true" />
    </staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />

服务器运行Windows Server 2008 R2与IIS7.5。我还安装了与放大器;启用动态的COM pression为有问题的网站。

The server is running Windows Server 2008 R2 with IIS7.5. I've also installed & enabled Dynamic Compression for the site in question.

任何帮助将是很大的AP preciated,因为我不希望启用JSON COM pression为整个服务器。

Any help would be greatly appreciated, as I do not wish to enable JSON compression for the entire server.

推荐答案

HttpCom pression 部分定义 AppHostOnly 对ApplicationHost.config 其prevents你在web.config中设置其属性。

HttpCompression section is defined AppHostOnly in ApplicationHost.config which prevents you from setting its properties in web.config.

在COM pression模块读取只能从对ApplicationHost.config服务器级属性,所以即使你解开段( APPCMD overrideModeDefault =允许),在较低的水平设置将被忽略。

The compression module reads only the server level properties from 'ApplicationHost.config' so even if you unlock the section (with appcmd or overrideModeDefault="Allow"), settings on lower level will be ignored.