如何转换这个web.config部分?

kat*_*tit 19 c# asp.net web-config

我有以下配置我的邮件:

<system.net>
    <mailSettings>
      <smtp from="foo@bar.com" deliveryMethod="SpecifiedPickupDirectory">
        <specifiedPickupDirectory pickupDirectoryLocation="C:/test"/>
        <network host="localhost" userName="" password=""/>
      </smtp>
    </mailSettings>
  </system.net>
Run Code Online (Sandbox Code Playgroud)

这是我的.Release版本:

<system.net>
    <mailSettings>
      <smtp from="foo@bar.com" xdt:Transform="RemoveAttributes(deliveryMethod)">
        <network xdt:Transform="Replace" host="192.168.1.9" userName="" password="" />
      </smtp>
    </mailSettings>
  </system.net>
Run Code Online (Sandbox Code Playgroud)

我该如何删除

<specifiedPickupDirectory pickupDirectoryLocation="C:/test"/>
Run Code Online (Sandbox Code Playgroud)

所以它根本没有显示在我的.Release中?

另外,我想System.Diagnostics完全删除其他名称空间.这样做的语法是什么?

Eug*_* S. 24

对于specifiedPickupDirectory元素,这应该工作:

<specifiedPickupDirectory xdt:Transform="RemoveAll" />.

对于System.Diagnostics:

<system.diagnostics xdt:Transform="RemoveAll"></system.diagnostics>


Baz*_*nga 16

<system.net>
    <mailSettings>
      <smtp from="foo@bar.com" xdt:Transform="Replace">
        <network xdt:Transform="Replace" host="192.168.1.9" userName="" password="" />
      </smtp>
    </mailSettings>
  </system.net>
Run Code Online (Sandbox Code Playgroud)

这将用你的整个标签取代..希望这就是你要找的......

关于这一点的好处是,你最终会用不必要的删除命令来污染你的转换配置,比如这里所说的一些答案.

考虑你有多个子标签的情况..