<system.webServer> <modules ...>在Web.Base.config中有效,但在Web.Debug / Release.Config中无效

时间:2019-07-24 12:50:36

标签: web-config global-asax

简单的问题。当我将下面的代码片段放入Web.Base.config中时,会击中MyModule.cs代码中的断点,但是当我将其放入Web.Debug.config

中时却没有命中。
<system.webServer>
  <modules>
    <add name="MyModule" type="MyNamespace.MyModule"/>
  </modules>
</system.webServer>

这是我在csproj文件中拥有的

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
<Target Name="BeforeBuild">
  <TransformXml Source="Web.Base.config" Transform="Web.$(Configuration).config" Destination="Web.config" StackTrace="true" />
</Target>

所以问题似乎在于Web.Base.config和Web。$(Configuration).config没有正确组合到生成的Web.config中

谢谢

1 个答案:

答案 0 :(得分:0)

好吧,我只是愚蠢。没有默认转换。为了使其正常工作,我需要在相应的行上指定xdt:Transform

<add name="MyModule" type="MyNamespace.MyModule" xdt:Transform="Insert"/>