【问题标题】:MVC Web.Debug.Config Question Concerning Debug ModeMVC Web.Debug.Config 关于调试模式的问题
【发布时间】:2014-09-01 19:34:30
【问题描述】:

这可能是一个快速的问题。我对解决方案配置和 web.config xml 文件转换非常陌生。我想添加一个转换来将 Asp.Net Mvc 网站的编译元素的调试属性设置为 true:

Web.Debug.config:

  <system.web>
    <compilation debug="true" xdt:Transform="SetAttributes(debug)" />
  </system.web>

Web.config:

<compilation targetFramework="4.0">
  <assemblies>
         ...
  </assemblies>
</compilation>

但是当我按下 F5 时,Visual Studio 中会弹出一个窗口,提示“该页面无法在调试模式下运行,因为在 web.config 文件中未启用调试。”然后它让我可以选择更改 Web.config 文件。但我认为 Web.Debug.config 文件的重点是允许它自动设置...我可以让 Visual Studio 在按 F5 后使用转换后的 Web.config 文件吗?

非常感谢!

安德鲁

【问题讨论】:

  • asp.net 不会读取 web.debug.config,除非您已将其添加到 web.config。所以在 web.config 上设置 debug=true,而不是在 web.debug.config 上。
  • @Aristos:感谢您的回复:) 我认为转换正在工作,但是当我按 F5 时它正在输出到调试目录而不是用于调试...

标签: asp.net asp.net-mvc-2 web-config


【解决方案1】:

好的,我决定改用以下设置:

Web.config:

<configuration>
    ...
  <system.web>    
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
          ...
      </assemblies>
    </compilation>
  </system.web>
    ...
</configuration>

Web.Release.config:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">

  <system.web>
    <compilation debug="false" xdt:Transform="SetAttributes(debug)" />
  </system.web>

</configuration>

当构建部署配置设置为“发布”时,这应该会导致编译调试属性被“false”覆盖。

【讨论】:

    【解决方案2】:

    根据我的经验,使用 F5 或 Visual Studio 调试器时不会发生转换。它仅在您发布网站后进行转换。

    【讨论】:

    【解决方案3】:

    试试这个

    < compilation xdt:Transform="RemoveAttributes(debug)" />
    

    【讨论】:

      【解决方案4】:

      在 Visual Studio 2013 中,如果您只有一个 web.config 文件,您可以右键单击它并选择“添加配置转换”。默认情况下,它包含

      <compilation xdt:Transform="RemoveAttributes(debug)" />
      

      删除 debug="true"。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-08-10
        • 1970-01-01
        • 1970-01-01
        • 2012-05-08
        • 1970-01-01
        • 1970-01-01
        • 2011-08-10
        • 1970-01-01
        相关资源
        最近更新 更多