发布时在服务器上更新了连接字符串



我正在尝试在发布期间在生产服务器上更新连接字符串值。我正在尝试以下操作,但没有结果:

<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时执行此操作并部署到生产教程。

https://learn.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations

最新更新