如何在 IIS 7 中使用 appcmd 更改 allowedDefinition 部分属性?

发布于 2024-07-16 15:41:01 字数 681 浏览 4 评论 0原文

是否可以使用appcmd更改allowDefinition的值? 具体来说,我尝试在应用程序级别启用对 httpCompression 模块的更改。

通过手动更改以下行来修改 applicationHost.config:

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

允许

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

我执行以下 appcmd 命令:

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

但是,我需要一个不依赖于手动编辑 applicationHost.config 的解决方案

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

微凉 2024-07-23 15:41:01

我的问题是,我必须将anonymousAuthentication从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

就是这样...:)

My problem was, I had to change anonymousAuthentication from False to True. When I did:
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")...

To unlock, do the following:
appcmd unlock config /section:? This will list the section you want. Then type:

appcmd unlock config /section:system.webserver/security/authentication/anonymousauthentication

Thats it... :)

も星光 2024-07-23 15:41:01

尝试使用 %windir%\system32\inetsrv\appcmd 解锁配置 -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]

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/

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]
相守太难 2024-07-23 15:41:01

一个重要的警告,你永远不应该更改allowDefinition,这是一个重要的设置,通常是有原因的,例如,即使你将它设置在特定的目录或应用程序中,它也可能不起作用,所以开发人员有指定了这一点。

因此,请不要修改节定义中的allowDefinition 属性。 另一方面,您可以修改 overrideModeDefault,这将允许用户在定义允许的情况下在不同的位置定义它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文