简体   繁体   中英

Nested web.config transform

I have a subdirectory with a simple web.config

<configuration>
  <system.web>
    <!--<authorization>
      <allow roles="admin"/>
      <deny users="*"/>
    </authorization>-->
  </system.web>
</configuration>

I like to have security turned off in development. I like to do a quick deploy - Alt-BH

Problem: Can I use my main web.release.config to take off the comments?

You can't remove comments with a config transform. However, you can remove the entire authorization element and all of its child elements.

Try placing the following in your Web.Debug.config:

<configuration>
  <system.web>
    <authorization xdt:Transform="Remove"/>
  </system.web>
</configuration>

I think you're looking at it the wrong way around Dave. Config transforms only get applied in a publish process which means when you're running locally (I assume this is what you mean by "turned off in development"), your web.config needs to be in the correct state for your local environment. If you don't want the auth node locally but you do want it remotely, you'll need config transforms to add it in the web.release.config file.

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