Reputation: 111
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.
Upvotes: 7
Views: 2248
Reputation: 1630
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:
C:\Windows\System32\inetsrv\appcmd.exe unlock config /section:system.webServer/httpCompression
2) Lets suppose you want to handle dynamic JSON requests (e.g. mimetype = application/json), you should use this command:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
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:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
Upvotes: 3
Reputation: 194
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?
Upvotes: 0