asp.net - 如何使用 web.config 转换在 APP 设置部分插入新密钥
问题描述
我想在应用设置部分插入新的键值,其他键值应该保持不变。
以下是我的源配置<
add key="UserName" value="Apple" />
<add key="Main.ConnectionString" value="Data Source=testingdevmachine;Persist Security Info=false;User ID=test;Password=test;Validate Connection=true;" />
<add key="CTCredentials01" value="userid@test|password@test&12|server@https://test/" />
<add key="WFCredentials01" value="userid@test|password@Mango| server@https://test/ />
`
我的转换配置文件如下所示:
<add key="CTCredentials01" value="userid@test123|password@test&12|server@https://test/" xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
<add key="WFCredentials01" value="userid@test123|password@Mango| server@https://test/"
xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
<add key="WFCredentials03" value="userid@test123|password@Mango| server@https://test/"
xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
<add key="UserName" value="Nick"
xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
现在,从上面的 transform config add key="WFCredentials03" 我的源配置文件中没有这个键,那么我如何在我的转换配置文件中添加这里?
解决方案
我建议你关注这篇文章,但从我上面看到的
<add key="WFCredentials03" value="userid@test123|password@Mango| server@https://test/"
xdt:Transform="SetAttributes" xdt:Locator="Match(key)"/>
你应该xdt:Transform="SetAttributes"
改为xdt:Transform="Insert"
推荐阅读
- angular - 如何在 Angular 2 中使用自定义指令
- python - PYGAME:碰撞无法正常工作。播放器和平台表现不佳。帮助,python的新手在这里
- oshi - 如何使用 OSHI 获取文件的 HWDiskStore?
- c# - 如何验证/验证 JWT 以访问数据 WCF asp.net
- python - 如何在情节表达中从树图的最外层块中删除悬停文本
- arrays - 谷歌表格从数据库中搜索并在编辑时插入特定单元格
- mysql - 带有 mysql 的 Ruby-on-rails Web 应用程序和带有 Firebase 的 Flutter 移动应用程序
- r - r编程-在数据框中如何将任何数字更改为列名
- python - 如何在python中定义屏幕
- python - python程序中的代数表达式简化