AFAIK, usual ASP.NET web site/web application switched on into DEBUG mode when web/app-config setting "compilation" has debug="false".
But I don't clearly understand how it works. Let's consider example:
I have <compilation debug="true" />
. I've added the following line into "Page_Load" method:
System.Diagnostics.Debug.WriteLine("Page_Load");
When I launched web-site in 'debug' mode (using F5 button) It put me 'Page_Load' into output window. Everything is ok so far.
When I change application compilation mode into non-debug:
Will it recompile everything for 'non-debug' mode? Is this enough to go into "production" environment with this change only?
I guess, it should be enough for web-site that doesn't use other project. Otherwise, I would better switch whole configuration into "Release" mode. In this case EACH project will be recompiled in "Release" mode.
Am I right? Could you please point me if something is wrong here?
Thanks a lot!
The point about your question is the difference between compiling in Visual Studio's Debug/Release modes and the Web.config's debug flag.
I'll try to explain you both.
First of all, you must get to know how an ASP.NET application is compiled, otherwise you won't understand the difference between the two compilations.
An ASP.NET application is made by markup (ie. .aspx pages, .ascx controls, .ashx .asmx marker files) and code-behind. Code-behind, from your IDE's point of view (no matter Visual Studio, MonoDevelop, etc.) is a .NET Class Library, ie. a set of classes that don't do anything alone. These can be compiled into Debug or Release mode indifferently by IDE setting. If you compile into Release mode, then calls to Debug
class will be ignored.
What about markup? When you start the web application, the markup files get compiled by the application server to get the final assemblies. For example, a Default.aspx
page with a code-behind file is compiled into a final class that inherits the code-behind class and writes to HTTP output all of its static parts, plus all the controls instantiated in the base class in the positions that have been chosen during design. Inline code (ie. <script runat=server>
tags) gets compiled too. In order to choose the compilation mode, the debug flag in Web.config is used, because you can't determine for sure if an assembly has been compiled in debug or release mode by simply reflecting on it (though there could be some empyrical criteria).
Debug
class from code-behind, make sure that your IDE compiles the website into Debug modeDebug
class from inline code in markup, make sure you have Web.config's debug flag setxbuild
it), I'm unsure but I believe the debug flag will be used for first compilation stage tooI hope I have been of help!