I have a subdirectory with a simple web.config
<configuration>
<system.web>
<!--<authorization>
<allow roles="admin"/>
开发者_StackOverflow社区 <deny users="*"/>
</authorization>-->
</system.web>
</configuration>
I like to have security turned off in development. I like to do a quick deploy - Alt-B-H
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.
精彩评论