相关疑难解决方法(0)

在IIS8中使用Gzip进行Json HTTP压缩

好的,我已经读了好几个小时了.数十个SO帖子和博客等.没有找到答案.

目标:从我的WCF服务启用json响应的动态http压缩.

注意:当applicationhost.config包含以下内容时,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/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/x-javascript" enabled="true" />
            <add mimeType="application/atom+xml" enabled="true" />
            <add mimeType="application/xaml+xml" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>    
</httpCompression>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

不幸的是在服务器上我使用applicationhost.config中缺少以下行:

<add mimeType="application/json; charset=utf-8" enabled="true" />
Run Code Online (Sandbox Code Playgroud)

而且我无法手动添加它,因为服务器是由Elastic Beanstalk启动的AWS EC2实例(因此我可以在一个实例上更改它,但在启动时不在所有实例上更改它).

还不幸的是,applicationhost.config包含以下行:

<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />
Run Code Online (Sandbox Code Playgroud)

这意味着我无法覆盖应用程序的web.config中的httpCompression部分.

我的问题:我是否应该尝试其他方法来启用动态内容的gzip压缩? …

asp.net iis wcf json gzip

5
推荐指数
1
解决办法
3944
查看次数

IIS7 GZIP压缩 - httpCompression部分

我试图httpCompression在IIS7 上配置.通过谷歌搜索,我发现它可以使用httpCompression配置中的部分.问题是,我无法通过web.config使其工作.

当我applicationHost.config根据需要在一切工作中进行配置时,我希望能够为每个应用程序而不是全局进行此配置.

我在改款的定义applicationHost.config,以<section name="httpCompression" overrideModeDefault="Allow" />和移动httpCompression部分的web.config:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/atom+xml" enabled="true" />
        <add mimeType="application/xaml+xml" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </staticTypes>
      <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/json; charset=utf-8" enabled="true" />
        <add mimeType="*/*" enabled="false" /> …
Run Code Online (Sandbox Code Playgroud)

iis-7 gzip web-config

3
推荐指数
1
解决办法
5343
查看次数

标签 统计

gzip ×2

asp.net ×1

iis ×1

iis-7 ×1

json ×1

wcf ×1

web-config ×1