ASP.NET Web.Config转换问题

Kev*_*vin 4 .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>
Run Code Online (Sandbox Code Playgroud)

我试图在我的使用中使用以下内容web.prod.config,但在发布项目时它不会添加属性.

<authentication mode="Forms" xdt:Transform="Replace">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" domain=".mydomain.com" />
</authentication>
Run Code Online (Sandbox Code Playgroud)

我希望输出如下.

<authentication mode="Forms">
    <forms loginUrl="~/Account/Login.aspx" timeout="2880" domain=".mydomain.com"/>
</authentication>
Run Code Online (Sandbox Code Playgroud)

Joh*_*ick 7

其中一个应该工作(未经测试,但基于Microsoft的文档):

<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>
Run Code Online (Sandbox Code Playgroud)

  • 您可以使用此工具测试配置转换:http://webconfigtransformationtester.apphb.com/ (3认同)