我一直在使用“C:\ Windows \ System32 \ inetsrv \ config”目录中的“applicationHost.config”文件,到目前为止一直很好,我只是想确定一些事情:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<staticTypes>
......
</staticTypes>
<dynamicTypes>
......
<add mimeType="application/json" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
如您所见,我添加了行<add mimeType="application/json" enabled="true" />
。这是否会确保只使用jquery进行动态Ajax调用?我使用:
$.ajax({
type: "POST",
url: 'someur.aspx/someMethod',
contentType: "application/json; charset=utf-8",
.....
我说错了吗?
答案 0 :(得分:1)
您需要添加2种内容类型才能为JSON启用动态压缩:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />
<!-- all other MIME type come here -->
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
</httpCompression>