4

如何使用web.config转换将域属性包含在我的制作中web.configASP.NET 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> 
+0

这与你的问题没有任何关系,而是域名确实是'=“。mydomain.com”'而不是'=“mydomain.com”'...应该在那里的时间段? – Kiril 2011-03-13 16:32:59

+1

谢谢,是的,点应该在那里,这将迎合子域,但很多谢谢。 – Kevin 2011-03-25 08:31:15

回答

6

其中这两个应该工作(未经测试,而是基于Microsoft's documentation):

<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> 
+0

对此延迟回复。我会在今天晚上尝试一下你的解决方案,让你知道。非常感谢您的帮助。 – Kevin 2011-03-25 08:31:48

+2

你可以使用这个工具测试配置转换:http://webconfigtransformationtester.apphb.com/ – friism 2011-09-14 15:50:32

+1

此外,这需要在 kmdsax 2014-04-02 20:53:56

3

没有看到全部的配置我不能肯定这会工作,但我会尝试添加一个定位器确保它抓住那条线并进行变革。

因此,而不是只是

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

将在这条道路符合这样的事

尝试

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

这将明确在了XPath拿起一个auth节点,其中, mode = Forms,它应该产生1并且只有1匹配到变换引擎并进行替换。

如果这不起作用,我会倒过来看看它是否可以转换(我怀疑),通过改变loginUrl来转换它,看看它是否出现在另一端。

你有可能在某个地方得到一个转换错误,它只是不适用。

+0

抱歉,对此延迟回复。我会在今天晚上尝试一下你的解决方案,让你知道。非常感谢您的帮助。 – Kevin 2011-03-25 08:32:18