c# - 发布时在服务器上更新连接字符串
问题描述
我正在尝试在发布期间在生产服务器上更新我的连接字符串值。我正在尝试以下没有结果:
<connectionStrings>
add name="DataConnect" connectionString="Server=Pepe;Database=Oyeti;Integrated Security=SSPI;" xdt:Transform="Replace" />
并且还添加了 xdt:Locator,但我认为这不是正确的方法:
<connectionStrings>
add name="DataConnect" connectionString="Server=Pepe;Database=Oyeti;Integrated Security=SSPI;" xdt:Transform="Replace" xdt:Locator="Match(name)" />
我在那里看不到什么?
谢谢!
解决方案
您可以将xdt:Transform="SetAttributes" xdt:Locator="Match(name)
属性添加到转换文件 (Web.Release.config) 中的 connectionString 标记,以转换主配置文件 (Web.config) 中的值。作为替代方案,您还可以在发布配置文件中指定连接字符串。
尽管默认转换文件包含一个显示如何更新连接字符串的示例,但在大多数情况下,您不需要设置连接字符串转换,因为您可以在发布配置文件中指定连接字符串。您将在部署到 IIS 和部署到生产教程中执行此操作。
推荐阅读
- dialogflow-es - DialogFlow:所有语言的训练短语数量限制为 10 个
- api - Magento 2.4.2:如何在我的自定义模块中获取实时当前汇率?
- python - 如何在python的列表中显示以下程序的输出?
- android - 如何使用 StreamProvider 返回子集合?[颤振,火力基地]
- azure-pipelines - 如何依赖特定的天蓝色管道矩阵作业而不是全部?
- authentication - 什么可能导致同一承载身份验证请求的身份凭证发生变化?
- python-3.x - 如何在 Django 中对非主键的 PUT 请求中发送 json 对象数组?
- google-admin-sdk - 将应用发布到 Google Workspace Marketplace 以查询其他组织的目录
- python - 具有多个数据集的 sklearn 模型选择
- c++ - 错误 C2064:术语不计算为采用 0 参数的函数,并且错误 E0980 调用没有适当 operator() 的类类型的对象