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

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

User Comments

Title: NIKE NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:11:27 AM
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes.
Title: SS   
Name: SS
Date: 2010-10-03 7:34:45 AM
Really a commedable effort for compiling all this in one article..
Title: The Honorable Lord   
Name: Confused
Date: 2009-12-22 2:27:19 PM
Sorry, the latest version of my post is the one to keep the older one can be discarded.
Title: The Honorable Lord   
Name: Confused
Date: 2009-12-22 2:08:55 PM
WINDOWS 7, VS 2008, IIS 7.5
Beautiful write-up. Saved me the time to do it myself.

But, confused: I still do not understand the realtionship betweent he web.config debug= switch and the Configuration Manager setting to Release/Debug ?

I keep 2 separate web.config files one for the HOST one for the dev machine.

My web.config on the HOST is set to debug=false.
I never have had need to compile on the HOST(I wonder if some scenarios require that! ...besides having to DEBUG on HOST for some reason.)
My web.config on the development machine is set to debug=true.
If I set it to false... and attempt to DEBUG... I get prompted to allow the IDE to change it to true for me...
I let it make the change and all is good, I am now allowed to debug.
ok, so far so good.

What I am confused about is the setting in the Configuration Manager(under BUILD option in VS). It is set to Release.
In my old WIN XP Pro dev env, I had to set that to DEBUG to be able to debug. In this new version, I leave it as Release.

So, when I compile(on dev machine)[dll version I will put on the HOST] I find myself making sure the debug= in the web.config is set to false.

Since the Configuration Manager setting is Release... should I not be able to simply leave the debug=true in the web.config on dev machine? Thus satisfying the benefit of avoiding to have to constantly change the setting?

Thus by implication it would mean the debug= switch in the web.config affects JIT only?

2 Notes:
- no matter how I set debug in either or both web.config or configuration manager, I get a pdb file.
- The Configuration Manager option under BUILD will not show until you visit the options and turn it on, on the latest version of VS <- what I nightmare that was to figure out.
Title: Pretty good   
Name: Anand
Date: 2009-11-25 11:58:15 PM
Pretty good and detailed. We are working on perf issues on a project. This helps a lot. Thanks.
Title: Web Developer   
Name: Raghav Khunger
Date: 2009-04-11 12:51:42 PM
Superb Article !!!!!!!!Great Explanation Rahul.
Title: For Gurpiar Singh   
Name: Rahul Soni
Date: 2008-08-01 6:24:59 PM
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.

Hope that helps,
Title: Software Architect   
Name: Gurpiar Singh
Date: 2008-08-01 6:05:52 PM
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: 2008-05-12 4:00:33 AM
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: 2007-08-22 11:11:48 AM
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...
Title: how about precompiled site   
Name: mILAN
Date: 2007-08-22 4:03:12 AM
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: 2007-08-21 7:12:10 PM
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: 2007-08-21 7:08:40 PM
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: 2007-08-18 5:01:36 AM
Great article!!!
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Sojesh
Date: 2007-08-15 2:02:47 PM
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: 2007-08-02 6:19:00 AM
This article is absolutely fantastic, MANY thanks :)
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Saurabh
Date: 2007-08-01 11:11:39 AM
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.


Product Spotlight
Product Spotlight 

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

©Copyright 1998-2020  |  Page Processed at 2020-05-30 7:58:54 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search