The Infamous Debug=True Attribute in ASP.NET
page 2 of 9
by Rahul Soni
Feedback
Average Rating: 
Views (Total / Last 10 Days): 35824/ 413

Problem #1

You will see a lot more files in Temporary ASP.NET files folder with debug=true.

Let us do a small exercise (meant only for Development machines and should not be done on a live server). I have created a simple website called DebugTrue in Visual Studio 2005. It has the following structure:

Figure 1 – Solution Explorer

As you can see, the Solution Explorer contains 5 files (Main.aspx, One.aspx, two.aspx, Global.asax and web.config) at the root level. There is a SomeFolder folder which contains two more files called Three.aspx and Four.aspx. Now navigate to C:\<WINDOWS>\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files folder and delete everything. If you are unable to delete, close the Visual Studio IDE and try again. If you still have issues, reset IIS. After that, double click on Main.aspx and you will see something as follows.

Figure 2 – List of files created automatically in Temporary ASP.NET Files folder

Notice that Global.asax got compiled automatically along with main.aspx. But so far, there are no signs of other ASPX files. Let us double click on Four.aspx in the Solution Explorer of the Visual Studio IDE and you will see something similar to Figure 3.

Figure 3 – Updated List of files after you double-click on four.aspx in Figure 1

Have a look at the difference and check how two more files get created as soon as you opened four.aspx in the IDE. This happens due to the automatic compilation model of Visual Studio 2005. Let us go one step further now; close the IDE and delete everything from the Temporary ASP.NET Files folder. Open the website in Visual Studio 2005 again and click on Build -> Build Web Site. Have a look at the folder and you will see something similar to the following.

Figure 4 – List of files when you build the website with debug=true in .NET 2.0

Hawk-eyed folks will have already noticed that .ccu files (Figure 2 & 3) are gone. Instead, you see App_Web_Random.n.vb. You can easily open most of the files in Notepad and check out what they contain. The moral of the exercise done so far is that you get a lot more files when you have debug = true. Open web.config and make debug=false. Remove all your Temporary files and build the website once again. Here is what I got.

Figure 5 – List of files when you build the website with debug=false in .NET 2.0

As you can see, there are just 9 objects in Figure 5 as against 34 objects in Figure 4 with debug=true. In .NET Framework 1.1 things were much worse and thus, much bigger performance impact. An application with the same structure but running under Framework 1.1 would show something like the following.

Figure 6 – List of files when you build the website with debug=true in .NET 1.1

Notice that now you have 6 assemblies (DLLs); one is for Global.asax and one is for each of the .aspx files! Thus, if you have 200 aspx files in your application there will be 200 DLLs sprayed across the memory. Let us turn debug=false and have a look at the Temporary files folder.

Figure 7 – List of files when you build the website with debug=false in .NET 1.1

 

You have just 3 assemblies now: 1 for Global.asax, 1 for all the files in root folder and 1 for all the files in SomeFolder folder.


View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 6 and 4 and type the answer here:

User Comments

Title: Web Developer   
Name: Raghav Khunger
Date: 4/11/2009 12:51:42 PM
Comment:
Superb Article !!!!!!!!Great Explanation Rahul.
Title: For Gurpiar Singh   
Name: Rahul Soni
Date: 8/1/2008 6:24:59 PM
Comment:
Your assumption is correct Gurpriar. This article mainly talks about the JIT.

There is a pretty neat feature in .NET 2.0 which talk about deployment retail="true" which is supposed to be set in Machine.Config file and that would ensure the .NET Runtime will assume as if debug="false" in all the web.config.

http://msdn.microsoft.com/en-us/library/ms228298.aspx

Hope that helps,
Rahul
Title: Software Architect   
Name: Gurpiar Singh
Date: 8/1/2008 6:05:52 PM
Comment:
We do have debug = false set in web.config on production servers
But we have debug=true set in web.config on Build Machine, where code gets compiled for deployment

And we compile code using MSBuild, with Configuration set to release mode.

The way our Continuous Integration is set up, there is no easy way for us to set this flag to false when code is getting compiled.

So, I am assuming your post applies only while the code is getting deployed and running in production, and not when code actually gets compiled.
Title: Webserver Optimization   
Name: Venkatesh R
Date: 5/12/2008 4:00:33 AM
Comment:
Thanks a ton for the Clear explanation. This Issue causing not only the application but the server resource utilization.
Title: For Milan   
Name: R S
Date: 8/22/2007 11:11:48 AM
Comment:
Hi Milan,

Thanks for your comments.

Precompiled websites are a way to deploy. Notice that you deploy the application under a folder, but not in the Temporary ASP.NET folder. So, although the website is already compiled, it is NOT JIT compiled.

To know more about JIT, you can visit...
http://msdn.microsoft.com/msdnmag/issues/05/05/JITCompiler/default.aspx
Title: how about precompiled site   
Name: mILAN
Date: 8/22/2007 4:03:12 AM
Comment:
How about precompiled websites (in .NET 2)? Since the website is already compiled, I don't think the case is same? Am I correct?
Title: For Craig   
Name: R S
Date: 8/21/2007 7:12:10 PM
Comment:
Hi Craig,

Thanks for your comments. I just wanted to confirm whether you are getting errors when Debug=True? If you are setting it to true, why?

Also, what is the complete error message you get. Do you see anything in the EventLogs?
Title: Why do I have issues when I do Debug=True   
Name: Craig
Date: 8/21/2007 7:08:40 PM
Comment:
Thanks for the article. I modified all the web.configs on my server and everything really starts blowing up. Mostly COM+ errors that reset W3WP.exe. Obviously, this is very bad for our customers. Why would this work fine when debug=false? Is there some underlying problem in our code that is being exposed?
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: .rip
Date: 8/18/2007 5:01:36 AM
Comment:
Great article!!!
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Sojesh
Date: 8/15/2007 2:02:47 PM
Comment:
Amazing stuff Rahul! Thanks for such a nice article showcasing every possible piece of information about the topic.... as usual!
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Dan
Date: 8/2/2007 6:19:00 AM
Comment:
This article is absolutely fantastic, MANY thanks :)
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Saurabh
Date: 8/1/2007 11:11:39 AM
Comment:
This is unarguably the best article i have read on "Debug=true" issue. The depth to which Rahul has gone to explain the repercussions of having debug set to true shoes his expertise and command over the subject.
Excellent job done! A must read for any Asp.Net enthusiast.

Saurabh

Product Spotlight
Product Spotlight 






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2009 ASPAlliance.com  |  Page Processed at 11/21/2009 6:56:24 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search