tags:

views:

696

answers:

2

Is it possible to use appcmd to change the value of allowDefinition? Specifically I'm try to enable changes to the httpCompression module at the application level.

Modifying the applicationHost.config by manually changing the following line:

<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />

To

<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />

allows me to then execute the following appcmd commands:

appcmd set config "website name" /section:httpCompression /noCompressionForProxies:false
appcmd set config "website name" /section:httpCompression /noCompressionForHttp10:false

However I need a solution that does not rely on manually editing the applicationHost.config

A: 

Try using %windir%\system32\inetsrv\appcmd unlock config -section:*sectionName*. See http://blog.donnfelker.com/category/IIS.aspx

I actually came across a need to do just that after posting this answer.

%systemroot%\System32\inetsrv\appcmd.exe unlock config /section:system.WebServer/[rest of the path to config section you need to edit]

tb
A: 

One big warning, you should NEVER change the allowDefinition, that is an important setting that is usually there for a reason, for example it might be that even if you set it in a specific directory or app it will not work, so the developers have specified that.

So please, never modify the allowDefinition attribute in the section definitions. On the other hand you can modify the overrideModeDefault which will allow users to define it in a different place if allowed by definition.

CarlosAg