Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set attributes in web.config only in release mode?

I want set this attribute only in release mode:

<system.web>
    <httpCookies domain=".mySite.com" />
  </system.web>

This is my Web.Release.Config:

<system.web>
<httpCookies name="someName" domain=".mySite.com"  xdt:Transform="SetAttributes" xdt:Locator="Match(name)" />
</system.web>

and this is my Web.Config:

<system.web>
        <httpCookies name="someName"/>
      </system.web>

But the httpCookies property not have name attribute!!! and get error that this attribute not valid.

like image 839
itmanir Avatar asked Dec 15 '22 06:12

itmanir


1 Answers

This should work - add this to your Web.Release.config file:

<system.web>
    <httpCookies domain=".mySite.com" xdt:Transform="Replace" />
</system.web>

You don't need the name attribute (it doesn't exist anyway)

This will be the result in the transformed web.config:

<system.web>
    <httpCookies domain=".mySite.com" />
</system.web>

Note that the httpCookies element must be present in your Web.config file for the transform to work.

like image 85
SteveChapman Avatar answered Dec 18 '22 12:12

SteveChapman