【问题标题】:tell appcmd to write configuration to the applicationhost.config rather then the site's web.config告诉 appcmd 将配置写入 applicationhost.config 而不是站点的 web.config
【发布时间】:2021-10-04 05:07:19
【问题描述】:

正如我 understand it 一样,可以在以下文件中将连接字符串和其他配置对象添加到站点范围 -

  1. machine.config
  2. applicationhost.config
  3. 网站的 web.config

我正在运行以下命令 -
APPCMD set config "site1" /section:ConnectionStrings /+"[ConnectionString='Data Source=localhost;Integrated Security=SSPI;', Name='Northwind', providerName='System.Data.SqlClient']"

这会在 web.config 文件中添加一个元素。
我想在 applicationHost.config 文件中看到它。

我尝试在 元素下手动添加它-

        <site name=...
             <connectionStrings>
                 <add connectionString="Data Source=localhost;Integrated Security=SSPI;" name="fromApplicatinoHost" providerName="System.Data.SqlClient " />
             </connectionStrings>
        </site>

但这不是 applicationHost 的合法语法。
那么如何将 connectionString 添加到 applicationHost ?

谢谢,

【问题讨论】:

  • ADO.NET 连接字符串应该转到根 web.config 或站点的 web.config。 applicationHost.config 不是一个选项。
  • Lex 你有相关文档的链接吗?谢谢 ! (顺便说一句,我有一个 VM,其中一些连接字符串在 machine.config 中)
  • 您可以在此doc 获取信息。它列出了存储连接字符串的所有可能方式和配置文件。 Machine.config、web.config、app.config,但没有 applicationhost.config。

标签: windows iis connection-string appcmd applicationhost


【解决方案1】:

您可以使用 /commit 参数来做到这一点。例如。
appcmd set config "ping" /section:system.webServer/security/authorization /+"[accessType='Allow',roles='administrators']" /commit:apphost
将授权写入应用程序主机。

更改站点上下文时的默认设置是写入站点的 web.config。 将/commit:machine 写入 machine.config。

完整的答案将包含完整的配置文件集,映射到文件的 appcmd 名称,但这也回答了我的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-11
    • 1970-01-01
    • 2010-09-09
    • 1970-01-01
    • 1970-01-01
    • 2020-01-23
    相关资源
    最近更新 更多