如何调试时,如何更改web.config以自动提供<customErrors mode ="Off"/>

3 asp.net-mvc asp.net-mvc-3 asp.net-mvc-4

在我的Web.Debug.config中我有这个:

  <system.web>
    <!--
      In the example below, the "Replace" transform will replace the entire 
      <customErrors> section of your Web.config file.
      Note that because there is only one customErrors section under the 
      <system.web> node, there is no need to use the "xdt:Locator" attribute.

      <customErrors defaultRedirect="GenericError.htm"
        mode="RemoteOnly" xdt:Transform="Replace">
        <error statusCode="500" redirect="InternalError.htm"/>
      </customErrors>
    -->
  </system.web>
Run Code Online (Sandbox Code Playgroud)

如何更改此设置以便将配置文件中的值更改为:

<customErrors mode="Off" /> to <system.web> 在web.config文件中

Chr*_*mes 6

Eonasdan 走在正确的道路上。

正确的方法是在调试配置中将错误设置为“关闭”。

在您的 Web.Release.config 中,使用转换:

<customErrors mode="Off" xdt:Transform="Replace">
</customErrors>
Run Code Online (Sandbox Code Playgroud)

这样,当您将代码推送到生产环境时,请使用 Visual Studio 下拉列表中的 Web.Release.config 文件,转换将替换 web.config 文件中的内容。


Eon*_*dan 5

只需将其更改为:

  <customErrors mode="Off" xdt:Transform="Replace">
  </customErrors>
Run Code Online (Sandbox Code Playgroud)