4

如何使用web.config转换将域属性包含在我的生产中web.config

我的基地有以下内容web.config

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>

我曾尝试在我的 中使用以下内容web.prod.config,但在发布项目时它没有添加该属性。

<authentication mode="Forms" xdt:Transform="Replace">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" domain=".mydomain.com" />
</authentication>

我希望输出如下。

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" domain=".mydomain.com"/>
</authentication>
4

2 回答 2

7

这两个之一应该工作(未经测试,但基于微软的文档):

<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>
于 2011-03-13T19:37:10.600 回答
3

在没有看到整个配置的情况下,我无法确认这会起作用,但我会尝试添加一个定位器以确保它抓住那条线并进行转换。

所以不仅仅是

<authentication mode="Forms" xdt:Transform="Replace">

这将匹配此路径中的任何内容

尝试

<authentication mode="Forms" xdt:Transform="Replace" xdt:Locator="Match(mode)"> 

这将显式地在该 xpath 处获取一个身份验证节点,其中 mode = Forms,它应该产生 1 并且只有 1 与转换引擎匹配并进行替换。

如果这不起作用,我会稍微反转一下,看看它是否完全转换(我怀疑),通过改变 loginUrl ni 转换只是为了看看它是否从另一边出来。

您可能会在某处遇到转换错误,而它只是不适用。

于 2011-03-14T18:22:13.097 回答