2012-01-09 59 views
0

我试图让web配置转变为正常,但没有成功合作。的web.config改造

我有一个文件夹中包含以下我的web应用程序:

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
    <authorization> 
     <allow roles="ADMINISTRATORS"/> 
     <allow roles="OPERATOR"/> 
     <deny users="?"/> 
    </authorization> 
    </system.web> 
</configuration> 

我创建的转换文件,我在发布移动区段变换版本。不幸的是,这是行不通的。 如果配置设置为调试,我不想在我的web配置中有该部分,否则我需要。

如何使工作有什么建议?

+2

你可以发表你的变换,你已经把发布一个内部的代码,并亲切地看一看http://msdn.microsoft.com? /en-us/library/dd465326.aspx – 2012-01-09 09:55:00

+0

有你看着http://msdn.microsoft.com/en-us/library/dd465326.aspx或http://msdn.microsoft.com/en-us/library /dd465318.aspx – Lloyd 2012-01-09 09:55:20

回答

2

感谢您的链接,我之前就看到过这些链接,但从未停下来阅读所有内容。

解决方法很简单(在设置:

<?xml version="1.0" encoding="utf-8" ?> 
<!-- For more information on using transformations 
    see the web.config examples at http://go.microsoft.com/fwlink/?LinkId=214134. --> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 

    <system.web> 
    <authorization> 
     <allow roles="ADMINISTRATORS" xdt:Transform="Insert"/> 
     <allow roles="OPERATOR" xdt:Transform="Insert"/> 
     <deny users="?" xdt:Transform="Insert"/> 
    </authorization> 
    </system.web> 

</configuration>