13

I am working on a site where we use Web.Debug.config with transform XSLT to turn custom errors off

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

However this doesn't seem to be taken into consideration when deploying to azure.

From

Azure web.config per environment

I can see that azure uses .cscfg files, and that what I am trying to accomplish will probably involve these files? What is the simplest way to turn custom errors off when deploying to azure but only when in debug?

Community
  • 1
  • 1
Tom
  • 12,591
  • 13
  • 72
  • 112

4 Answers4

16

From Visual Studio 2015, for an "App Service", open Server Explorer and navigate to Azure -> App Service -> {resource group name} -> {app service name} -> Files -> Web.config.

At this point, you can edit the Web.Config file directly and save it - no publish required.

James
  • 2,823
  • 22
  • 17
9

However this doesn't seem to be taken into consideration when deploying to azure

Probably because your normal web.config doesn't contain a element (I had the same problem today). Of course your transform of 'replace' can only be applied if there actually is something to be applied.

What is the simplest way to turn custom errors off when deploying to azure but only when in debug?

There's a debug web.config and a release web.config (you can expand the web.config). Apply the production transformations in the release one and the debug transformations in the debug one.

Leon Cullens
  • 12,276
  • 10
  • 51
  • 85
  • 1
    Ttrue, but he could make a new build configuration just for packaging. –  May 31 '12 at 19:59
8

The fact is that anything you will add into web.release.config or web.debug.config will not be included in the final web.config which will be the part of your application Package (CSPKG) deployed to Windows Azure. If you wish to have certain web.config settings part of your Windows Azure application, you will have to explicit define in web.config.

To turn custom errors Off, you would add the following explicitly in web.config:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  ......
  <system.web>
   <customErrors mode="Off" xdt:Transform="Replace"/>
  </system.web>
 .....
</configuration>
AvkashChauhan
  • 20,495
  • 3
  • 34
  • 65
  • 3
    So when deploying to azure it ignores the transforms? Am a bit confused, the code sample you've given is a transform? – Tom Jun 01 '12 at 10:04
  • No he is saying that web.debug.config and web.release.config's are not taken into consideration. – Burak Karakuş Dec 17 '15 at 08:43
1

You need have this line in web.config

<customErrors mode="Off"/>

And in web.config.release

<system.web>
     <customErrors mode="Off" xdt:Transform="Replace"/> 
    <compilation xdt:Transform="RemoveAttributes(debug)" />    
  </system.web>

When use 1 click publish, it will replace from web.config.release to web.config So, if web.config don't have customErrors tag, it will ignore

Wolf
  • 6,361
  • 2
  • 28
  • 25