Custom errors per environment in the web.config

Has anyone ever asked for a feature to easily toggle custom errors (more easily than a configuration transform?)

Obviously custom errors should be on for production systems - but it is nice for devs to get the errors remotely on dev systems (vs the yellow screen) :slight_smile:



Hi Blake,

We do get similar requests. What I would do is define a variable called CustomErrorsOff and set it to True for the environments you want. Then add the following script as a post deploy script in the step, or as a PostDeploy.ps1 script in the root of your package:

if($CustomErrorsOff -eq "True") {
    $file = "Web.config"
    $xml = [xml](Get-Content $file)
    $xml.SelectNodes("//configuration/system.web/customErrors") | % { 
        $_.mode = "On"


Hope that helps

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.