【问题标题】:Set '<location overrideMode="Allow"...' programmatically in applicationHost.config在 applicationHost.config 中以编程方式设置 '<location overrideMode="Allow"...'
【发布时间】:2012-12-18 12:18:09
【问题描述】:

我需要允许我正在安装的站点覆盖错误页面委托,以便它能够正常运行,而不会影响 Web 服务器上的任何其他站点或设置。

首先我尝试使用 C# 自定义操作编辑 Xml,但即使自定义操作以完全管理员权限运行,它也找不到文件 (FileNotFoundException)。我已经对 AppCmd.exe 进行了各种尝试,但我没有设法以任何我能看到的方式更改 applicationHost.config,更不用说我想要的方式了(overrideMode="Allow")。我很难理解为什么因为这很容易手动更改,所以在代码中是如此困难。

此尝试背后的原因是,如果错误处理的根级别功能委托设置为“只读”,我不希望出现 500.19 HTTP 错误。换句话说,我只想安装我的应用程序。

【问题讨论】:

  • 这个问题你解决了吗?

标签: iis custom-action appcmd


【解决方案1】:

这是我用来解锁system.webServer/security/ipsecurity 部分的命令:

C:\Windows\System32\inetsrv>appcmd unlock config /section:system.webServer/secur
ity/ipsecurity
Unlocked section "system.webServer/security/ipSecurity" at configuration path "M
ACHINE/WEBROOT/APPHOST".

注意:这必须通过提升的命令提示符(以管理员身份运行)运行。

更多信息请访问Getting Started with AppCmd.exe

【讨论】:

  • 谢谢。希望我很快有机会尝试一下,我对此表示怀疑,但我会尝试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-07-10
  • 2014-09-08
  • 2015-07-24
  • 1970-01-01
  • 1970-01-01
  • 2021-11-21
  • 2018-11-26
相关资源
最近更新 更多