Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 doesn'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>
like image 564
Kevin Avatar asked Dec 29 '22 00:12

Kevin


1 Answers

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>
like image 191
John Pick Avatar answered Jan 03 '23 14:01

John Pick