开发者

Web.config Transform

开发者 https://www.devze.com 2023-03-15 22:31 出处:网络
I have a config that has multiple connection strings.They all point to the same database server.Is开发者_如何学Go there a way to replace a portion of the web.config, i.e.

I have a config that has multiple connection strings. They all point to the same database server. Is开发者_如何学Go there a way to replace a portion of the web.config, i.e.

<connectionStrings>
<add name="Conn1" connectionString="...DataSource=server1;Initial Catalog=DBName..." />
<add name="Conn2" connectionString="...DataSource=server1;Initial Catalog=DBName2..." />
</connectionStrings>

I want to change server1 with server 2. I could do this...

<add xdt:Transform="SetAttributes" xdt:Locator="Match(name)" name="Conn1" connectionString="...DataSource=server2;Initial Catalog=DBName..." />
<add xdt:Transform="SetAttributes" xdt:Locator="Match(name)" name="Conn2" connectionString="...DataSource=server2;Initial Catalog=DBName..." />

but wanted to see if there was a more all-inclusive way.


According the msdn documentation of web.config transformation there is no possibility for this kind of transformation. You can only do Replace, Insert, InsertBefore, InsertAfter, Remove, RemoveAll, RemoveAttributes and SetAttributes transformations.

0

精彩评论

暂无评论...
验证码 换一张
取 消