ASP.NET Web.Config Conversion Problem

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

My web.config database has the following:

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

I tried using the following in my web.prod.config , but it does not add an attribute when publishing the project.

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

I would like the result to be as follows.

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

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

Without looking at the whole configuration, I can’t confirm that this will work, but I would try adding a locator to make sure that it has captured this line and performed the conversion.

So instead of just

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

What will fit this in this way

Try

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

which will explicitly take the auth node in this xpath, where mode = Forms, which should give 1 and only 1 match the conversion mechanism and do the replacement.

If this does not work, I would change it a little, if its conversion at all (which I doubt), changing the value of loginUrl ni to see if it comes out on the other side.

Most likely, you get a conversion error somewhere and just do not apply it.

+3
source

Source: https://habr.com/ru/post/1343540/


All Articles