简体   繁体   中英

Web.config debug/release, changing a value

Currently my web.config file has this:

<system.web>
    <httpCookies httpOnlyCookies="true" requireSSL="true" />
</system.web>

I want requireSSL to be "true" in release and "false" in debug. How do I do this?

Web.config does not support conditional statements.

This is typically handled in deployment. You can use transformation files. https://msdn.microsoft.com/en-us/library/dd465318(v=vs.100).aspx

Put this in your Web.Release.config file:

<httpCookies requireSSL="true" xdt:Transform="SetAttributes(requireSSL)"/>

Here's a handy tool from AppHarbor for testing the results of your transformations: https://webconfigtransformationtester.apphb.com/

I think this is something you are looking for

Web.Config Debug/Release

Please check this one

xdt:Transform="SetAttributes" xdt:Locator="Match(name)"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM