1

在我的 Web.Config 我有以下

<configuration>
  <configSections>
   /*some code*/
  </configSections>
  <appSettings>
    <add key="KeyName" value="KeyValue"/>
  </appSettings>
</configuration>

我在部署 Web 应用程序项目时使用了以下代码。

{
  "QA": {
    "ConfigChanges": [
      {
        "KeyName": "/configuration/appSettings/add[@key='KeyName']",
        "Attribute": "value",
        "Value": "NewKeyValue"
      }
    ]
  }
}

上面的代码找到带有 appkey 名称的配置并覆盖它。但是如果它没有任何密钥,我们如何配置,比如 smtp 设置?

<system.net>
  <mailSettings>
    <smtp from="" deliveryMethod="Network">
      <network host="smtp.gmail.com" port="57" defaultCredentials="true"  />
    </smtp>
  </mailSettings>
</system.net>

我尝试像下面一样使用密钥,但我得到了错误。

{
 "KeyName":"/configuration/system.net/mailSettings/smtp/network[@defaultCredentials='true']",
 "Attribute": "host",
 "Value": "test.com"
}

更新 /configuration/system.net/mailSettings/smtp/network[@defaultCredentials='true'] 的端口时失败:25

你能帮我解决这个问题吗?

4

0 回答 0