如何使用config transform删除web.config中的模块

时间:2015-06-15 19:37:30

标签: asp.net web-config web.config-transform

我的web.config中有一段如下所示:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
    <remove name="WebDAVModule" />
    <add name="ImageResizingModule" type="ImageResizer.InterceptModule" />
    <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
    <add name="Prerender" type="Prerender.io.PrerenderModule, Prerender.io, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null" />
</modules>

我想摆脱这条线

我已经尝试过了,但除了WebDav之外它已经完全消除了

<system.webServer>
<rewrite xdt:Transform="Replace">
  <rules>
  </rules>
</rewrite>
<modules runAllManagedModulesForAllRequests="true">
  <add name="Prerender" type="Prerender.io.PrerenderModule, Prerender.io, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null" 
       xdt:Transform="RemoveAll" />
</modules

1 个答案:

答案 0 :(得分:2)

您可以使用Refactor->Rename...xdt:Transform="Remove"的组合,如下所示:

xdt:Locator="Match(name)"

在这种情况下,上面将删除按名称匹配的模块<system.webServer> <modules runAllManagedModulesForAllRequests="true"> <remove name="WebDAVModule" /> <add name="ImageResizingModule" type="ImageResizer.InterceptModule" xdt:Transform="Remove" xdt:Locator="Match(name)" /> <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /> <add name="Prerender" type="Prerender.io.PrerenderModule, Prerender.io, Version=1.0.0.2, Culture=neutral, PublicKeyToken=null" /> </modules> </system.webServer>

预览的屏幕截图

Screen shot of preview