0

我正在尝试使 Web 配置转换正常工作,但没有成功。

我的网络应用程序中有一个文件夹,其中包含以下内容:

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

我创建了转换文件,并在 Release 转换版本中移动了部分。不幸的是,这不起作用。如果配置设置为调试,我不想在我的网络配置中包含该部分,否则我需要。

有关如何使其工作的任何建议?

4

1 回答 1

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>
于 2012-01-10T08:10:29.567 回答