在 IIS7.5 中未读取 web.config 中的 HttpCompression 元素
我试图覆盖运行 Windows 7 的 IIS 7.5 上的网站的 Web.config 中的 httpCompression
元素,但它似乎根本不被读取。
为了检查,我在元素中引入了 typeos,但我什至无法得到配置错误。
这是 Web.config 中的 httpCompression
元素的示例
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<SCHEMEx name="deflate" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="false" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTUPES>
</staticTUPES>
</httpCompression>
当我在其他元素(如 modules
)中引入类似错误时,我收到配置错误,所以我知道配置文件被读取。
我已经解锁了 ApplicationHost.config 中的部分:
appcmd unlock config /section:system.webserver/httpcompression
但这不起作用,所以我手动更改了 ApplicationHost.config,所以它现在显示为:
...
<section name="httpCompression" overrideModeDefault="Allow" />
...
我真正想要完成的是将“deflate”设置为唯一的压缩方案我的网站。
I'm trying to override the httpCompression
element within Web.config for a site on an IIS 7.5 running Windows 7, but it does not seem to be read at all.
To check, I've introduced typeos within the element, but I can't even get a configuration error.
Here is an example of the httpCompression
element from Web.config
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<SCHEMEx name="deflate" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="false" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTUPES>
</staticTUPES>
</httpCompression>
When I introduce similar errors in other element (like ie modules
) I get a configuration error, so I know the config file is read.
I've unlocked the section in ApplicationHost.config:
appcmd unlock config /section:system.webserver/httpcompression
But that did not work, so I changed ApplicationHost.config manually so it now reads:
...
<section name="httpCompression" overrideModeDefault="Allow" />
...
What I'm really trying to accomplish is to set "deflate" as the only compression scheme for one of my sites.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我之前也遇到过类似的问题,时间太久了记不清了。我想我直接对 ApplicationHost.config (%windir%\system32\inetsrv\config) 进行更改,但这不是理想的解决方案。
假设你已经看过这里
http://www.iis.net/configreference/system.webserver/httpcompression -
您是否尝试过使用本文中提到的 clear 元素?
I had a slightly similar problem before, too long ago to remember in detail. I think I resorted to making the changes directly to the ApplicationHost.config (%windir%\system32\inetsrv\config), but not an ideal solution.
Assume you've looked here
http://www.iis.net/configreference/system.webserver/httpcompression -
Have you tried using the clear element as mentioned in this post?
为此,在解锁 application.config 文件后,您还必须通过命令行设置特定配置。
1) 解锁 application.config 的 httpCompression 部分:
2) 让我们假设您想要处理动态 JSON 请求(例如 mimetype = application/json),您应该使用以下命令:
3) 如果 JSON 请求是您的情况,您可能还需要处理 charset=utf -8 变化,由于某种原因,大多数情况下 IIS 都会返回给您:
For this to work, after unlocking the application.config file you have to set the specific configuration via command line as well..
1) Unlock the httpCompression part of the application.config:
2) Lets suppose you want to handle dynamic JSON requests (e.g. mimetype = application/json), you should use this command:
3) If JSON requests is your case, you might also want to handle the charset=utf-8 variation, which for some reason is what IIS gives you back in most cases: