是否可以使用appcmd来更改allowDefinition的值?具体来说,我尝试在应用程序级别启用对httpCompression模块的更改.
通过手动更改以下行来修改applicationHost.config:
<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />
Run Code Online (Sandbox Code Playgroud)
至
<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
Run Code Online (Sandbox Code Playgroud)
然后允许我执行以下appcmd命令:
appcmd set config "website name" /section:httpCompression /noCompressionForProxies:false
appcmd set config "website name" /section:httpCompression /noCompressionForHttp10:false
Run Code Online (Sandbox Code Playgroud)
但是,我需要一个不依赖于手动编辑applicationHost.config的解决方案
小智 5
我的问题是,我不得不将匿名身份验证从False更改为True.当我这样做: appcmd set config websitename/section:anonymousAuthentication/enabled:True
我遇到错误:配置错误此配置无法在此路径中使用.当该部分在父级别锁定时会发生这种情况.默认锁定(overrideModeDefault ="Deny")...
要解锁,请执行以下操作: appcmd unlock config/section:? 这将列出您想要的部分.然后输入:
appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication
而已... :)
尝试使用%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/
实际上,在发布此答案后,我发现需要这样做。
%systemroot%\System32\inetsrv\appcmd.exe unlock config /section:system.WebServer/[rest of the path to config section you need to edit]
Run Code Online (Sandbox Code Playgroud)