user3231982
user3231982

Reputation: 45

ASP.net Website want debug to == false on IIS

Have tried adding this to web.config

<compilation debug="false" targetFramework="4.0">
</compilation>

but website still executes code in #if DEBUG when it shouldn't

*Wierdly the inline statement <% #if DEBUG %> on aspx files works but require also for .cs code.

NB development and live website on same box

Upvotes: 0

Views: 336

Answers (3)

Steven V
Steven V

Reputation: 16595

Ensure the compile configuration to release as well. In Visual Studio, Build Menu > Configuration Manager and make sure "Release" is selected for all your assemblies, and/or is the active solution configuration.

Upvotes: 0

Jakub Konecki
Jakub Konecki

Reputation: 46008

compilation debug element is not the same thing as DEBUG preprocessor directive. You need to re-compile your website in Release mode.

What about binaries compiled with debug symbols?

One scenario that several people find very useful is to compile/pre-compile an application or associated class libraries with debug symbols so that more detailed stack trace and line error messages can be retrieved from it when errors occur.

The good news is that you can do this without having the have the switch enabled in production. Specifically, you can use either a web deployment project or a web application project to pre-compile the code for your site with debug symbols, and then change the switch to false right before you deploy the application on the server.

The debug symbols and metadata in the compiled assemblies will increase the memory footprint of the application, but this can sometimes be an ok trade-off for more detailed error messages.

http://weblogs.asp.net/scottgu/archive/2006/04/11/Don_1920_t-run-production-ASP.NET-Applications-with-debug_3D001D20_true_1D20_-enabled.aspx

Upvotes: 0

SLaks
SLaks

Reputation: 888107

#if directives in backend .cs files are handled by the C# compiler, not ASP.Net.
Set your project to the Release configuration so that that symbol is not defined when compiling the DLL in VS.

Upvotes: 1

Related Questions