开发者

ASP.NET Web.Config Transformation Issue

How can I use a web.config transform to include the domain attribute in my production web.config?

I have the following in my base web.config.

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

I have tried to use the following in my web.prod.config, but it does开发者_如何学编程n't add the attribute when I publish the project.

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

I would like the output to be the following.

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


One of these two should work (untested, but based on 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>


Without seeing the entire config I can't confirm this will work, but I would try adding a locator to make sure its grabbing that line and doing the transform.

So instead of just

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

Which will match anything like this in this path

Try

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

which will explicitly pick up an auth node at that xpath, where the mode = Forms, which should yield 1 and only 1 match to the transform engine and do the replacement.

If that doesn't work, I'd reverse a bit to see if its transforming at all (which I doubt), by changing the loginUrl ni the transform just to see if it comes out the other side.

Chances are you are getting a transform error somewhere and its just not applying.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜