user1943020
user1943020

Reputation:

How can I change my web.config to give <customErrors mode="Off" /> automatically when I debug

In my Web.Debug.config I have this:

  <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>

How can I change this so that it changes the value in the config file to:

<customErrors mode="Off" /> to <system.web> in the web.config file

Upvotes: 7

Views: 7248

Answers (2)

Chris Holmes
Chris Holmes

Reputation: 11584

Eonasdan is on the right track.

The correct way to do this is, in your debug config, set the errors to "Off".

In your Web.Release.config, use a transform:

<customErrors mode="Off" xdt:Transform="Replace">
</customErrors>

This way, when you push your code to production, use the Web.Release.config file in the Visual Studio dropdown, and the transform will replace what is in the web.config file.

Upvotes: 6

Eonasdan
Eonasdan

Reputation: 7765

Just change it to this:

  <customErrors mode="Off" xdt:Transform="Replace">
  </customErrors>

Upvotes: 6

Related Questions