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.
是否可以使用appcmd来更改allowDefinition的值?具体来说,我尝试在应用程序级别启用对httpCompression模块的更改。
Modifying the applicationHost.config by manually changing the following line:
通过手动更改以下行来修改applicationHost.config:
<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命令:
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
但是,我需要一个不依赖于手动编辑applicationHost.config的解决方案
3 个解决方案
#1
My problem was, I had to change anonymousAuthentication from False to True. When I did: appcmd set config websitename /section:anonymousAuthentication /enabled:True
我的问题是,我不得不将anonymousAuthentication从False更改为True。当我这样做:appcmd set config websitename / section:anonymousAuthentication / enabled:True
Error I got: Config Error This configuration cannot be used at this path. This happens when the section is locked at the parent level. Locking is either by default(overrideModeDefault="Deny")...
我遇到错误:配置错误此配置无法在此路径中使用。当该部分在父级别锁定时会发生这种情况。默认情况下锁定(overrideModeDefault =“Deny”)...
To unlock, do the following: appcmd unlock config /section:? This will list the section you want. Then type:
要解锁,请执行以下操作:appcmd unlock config / section:?这将列出您想要的部分。然后输入:
appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication
appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication
Thats it... :)
而已... :)
#2
Try using %windir%\system32\inetsrv\appcmd unlock config -section:*sectionName*
. See http://blog.donnfelker.com/2007/03/26/iis-7-this-configuration-section-cannot-be-used-at-this-path/
尝试使用%windir%\ system32 \ inetsrv \ appcmd unlock config -section:* sectionName *。见http://blog.donnfelker.com/2007/03/26/iis-7-this-configuration-section-cannot-be-used-at-this-path/
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]
#3
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.
一个重要的警告,你永远不应该改变allowDefinition,这是一个重要的设置,通常有一个原因,例如它可能是即使你在特定的目录或应用程序中设置它将无法工作,所以开发人员有指定的。
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.
所以请永远不要修改节定义中的allowDefinition属性。另一方面,您可以修改overrideModeDefault,允许用户在定义允许的情况下在不同的位置定义它。
#1
My problem was, I had to change anonymousAuthentication from False to True. When I did: appcmd set config websitename /section:anonymousAuthentication /enabled:True
我的问题是,我不得不将anonymousAuthentication从False更改为True。当我这样做:appcmd set config websitename / section:anonymousAuthentication / enabled:True
Error I got: Config Error This configuration cannot be used at this path. This happens when the section is locked at the parent level. Locking is either by default(overrideModeDefault="Deny")...
我遇到错误:配置错误此配置无法在此路径中使用。当该部分在父级别锁定时会发生这种情况。默认情况下锁定(overrideModeDefault =“Deny”)...
To unlock, do the following: appcmd unlock config /section:? This will list the section you want. Then type:
要解锁,请执行以下操作:appcmd unlock config / section:?这将列出您想要的部分。然后输入:
appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication
appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication
Thats it... :)
而已... :)
#2
Try using %windir%\system32\inetsrv\appcmd unlock config -section:*sectionName*
. See http://blog.donnfelker.com/2007/03/26/iis-7-this-configuration-section-cannot-be-used-at-this-path/
尝试使用%windir%\ system32 \ inetsrv \ appcmd unlock config -section:* sectionName *。见http://blog.donnfelker.com/2007/03/26/iis-7-this-configuration-section-cannot-be-used-at-this-path/
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]
#3
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.
一个重要的警告,你永远不应该改变allowDefinition,这是一个重要的设置,通常有一个原因,例如它可能是即使你在特定的目录或应用程序中设置它将无法工作,所以开发人员有指定的。
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.
所以请永远不要修改节定义中的allowDefinition属性。另一方面,您可以修改overrideModeDefault,允许用户在定义允许的情况下在不同的位置定义它。