Web 配置转换语法
我一直在关注Web Config Transformation的MSDN指南,并且大体上已经有了成功了。
然而,我的网络配置中的一行给我带来了麻烦,我只能假设这是因为我误解了指南并使用了错误的语法。
我希望有人能够指出我的错误,如果是这样,我将不胜感激。
转换中的违规行是:
<sessionState sqlConnectionString="data source=localhost;uid=userId;pwd=password;" xdt:Transform="SetAttributes(sqlConnectionString)" />
原始 Web 配置中的行是:
<sessionState mode="SQLServer" sqlConnectionString="data source=networkAlias;uid=userId;pwd=password;" cookieless="UseDeviceProfile" timeout="120" />
我希望转换能够替换属性“sqlConnectionString”,从而更改连接详细信息。不幸的是,线路没有受到影响。
我使用了完全相同的语法:
<network host="localhost" xdt:Transform="SetAttributes(host)" />
上面的效果很好,所以我假设它也是如此。
谁能看到我哪里出错了?
I've been following the MSDN guide for Web Config Transformation and by-and-large have had success with it.
However, one line of my web config is giving my troubles and I can only assume it's because I'm misunderstanding the guide and using the wrong syntax.
I'm hopeful that someone will be able to point out my mistake, and will be grateful if that's the case.
The offending line in the transform is:
<sessionState sqlConnectionString="data source=localhost;uid=userId;pwd=password;" xdt:Transform="SetAttributes(sqlConnectionString)" />
The line in the original web config is:
<sessionState mode="SQLServer" sqlConnectionString="data source=networkAlias;uid=userId;pwd=password;" cookieless="UseDeviceProfile" timeout="120" />
My hope was that the transform would replace the attribute "sqlConnectionString", changing the connection details. Unfortunately the line is unaffected.
I've used exactly the same syntax for:
<network host="localhost" xdt:Transform="SetAttributes(host)" />
The above works just fine, so I had assumed it would be the case for the too.
Can anyone see where I'm going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
只是一个简单的错字。您需要将 sqlConnectionString 更改为 stateConnectionString。您在 web.config 中拥有它,但没有转换。否则,变换看起来不错。
您需要在此处更改 sqlConnectionString:
到 stateConnectionString:
Just a simple typo. You need to change sqlConnectionString to stateConnectionString. You have it right in the web.config, but not the transformation. Otherwise, the transform looks good.
You need to change sqlConnectionString here:
To stateConnectionString: