2012-01-09 45 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>