ASP.NET Web.Config转换问题
如何使用ASP.NET Web.Config转换问题,.net,asp.net,authentication,web-config,web-config-transform,.net,Asp.net,Authentication,Web Config,Web Config Transform,如何使用web.config转换在我的产品web.config中包含域属性 我的基本web.config中有以下内容 <authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication> 我希望输出如下 <authentication mode="Forms"> <forms login
web.config
转换在我的产品web.config
中包含域属性
我的基本web.config
中有以下内容
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
我希望输出如下
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" domain=".mydomain.com"/>
</authentication>
这两种方法中的一种应该有效(未经测试,但基于):
在看不到整个配置的情况下,我无法确认这是否可行,但我会尝试添加一个定位器,以确保它抓住该行并进行转换 因此,与其只是
<authentication mode="Forms" xdt:Transform="Replace">
这将匹配此路径中的任何类似内容
试一试
它将显式地在该xpath处拾取一个auth节点,其中mode=Forms,这将产生1个,并且只有1个匹配到转换引擎并进行替换
如果这不起作用,我会反转一点,看看它是否在转换(我对此表示怀疑),通过改变loginUrl来改变转换,看看它是否从另一面出来
很可能您在某个地方遇到了转换错误,但它不适用。这与您的问题无关,但域是否真的
=”.mydomain.com“
而不是=“mydomain.com”
。。。这段时间应该在那里吗?谢谢,是的,dot应该在那里,这将迎合一个子域名,但非常感谢。很抱歉延迟回复。今晚我会试试你的解决方案,然后告诉你。非常感谢您的帮助。您可以使用此工具测试配置转换:此外,这需要在@kmdsax中。您是我的英雄,完成后,上面的答案有效。John Pick能否更新您的wanswer以包含此重要细节?很抱歉延迟回复。今晚我会试试你的解决方案,然后告诉你。非常感谢你的帮助。
<system.web>
<authentication mode="Forms" xdt:Transform="Replace" xdt:Locator="Match(forms)">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" domain=".mydomain.com" />
</authentication>
</system.web>
<system.web>
<authentication mode="Forms">
<forms domain=".mydomain.com" xdt:Transform="SetAttributes(domain)" />
</authentication>
</system.web>
<authentication mode="Forms" xdt:Transform="Replace">
<authentication mode="Forms" xdt:Transform="Replace" xdt:Locator="Match(mode)">