Asp – Possible to use preprocessor directives in web.config

asp.net

I'd like to be able to do this so that I could do something like:

#if DEBUG
    <!--<customErrors mode="On" defaultRedirect="Error.aspx" />-->
#else
    <customErrors mode="On" defaultRedirect="Error.aspx" />

Possible? Would make life a little easier.

Best Answer

You can use something called a "Web Deployment Project" to swap out different config sections.

Just add custom .config files to your soulution and configure the WDP.

After that, you can just point the debug location to the deploy location and you should be set.