我一直在努力启用我们MVC3网站的JSON压缩。根据我阅读的各种文章,似乎应该能够在应用程序的web.config文件中设置
application/json; charset=utf-8
MIME类型。但是这样做并没有启用压缩。但是当添加到applicationhost.config文件中时,它可以正常工作。我错过了什么吗?我的应用程序web.config文件已添加以下内容:<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。我还为涉及的站点安装并启用了动态压缩。
如有帮助将不胜感激,因为我不希望为整个服务器启用JSON压缩。