The Infamous Debug=True Attribute in ASP.NET
page 1 of 9
Published: 02 Aug 2007
Abstract
In this article Rahul demonstrates how badly compilation debug="true" hurts your application’s performance and why it does this with the help of code samples.
by Rahul Soni
Feedback
Average Rating: 
Views (Total / Last 10 Days): 127533/ 172

Introduction

You probably will not believe it when I simply tell you that <compilation debug="true"> can hurt your application’s performance as bad as it does in ASP.NET production websites! I have already seen a lot of really good articles and blog posts related to this topic telling what can go wrong when you have debug set to true in ASP.NET production websites. In this article I will try to show it in a little more detail so that you are well informed on this attribute and why I am asking you to turn it off in production websites.

NOTE: Going forward in this article, wherever I say web.config I mean web.config in your production websites (and not in development machines) until mentioned otherwise explicitly. Also, I am not talking about the global web.config which comes with .NET 2.0. I am just talking about all the web.config files in the root directory of your ASP.NET application’s Virtual Directory/Website. Changing anything in your web.config will raise a File Change Notification event and your application domain will recycle and your application users might get logged off if you are using In Process sessions. So, if you want to make any changes to any of the web.config files, do it in your application's maintenance time.

NOTE: Although I am using Microsoft Visual Web Developer 2005 Express Edition for all the samples, I will cover both .NET 1.1 and 2.0 in this article.

If you do not want to read the nitty-gritty of this attribute and trust me straight away, find all your web.config files with <compilation debug=“true”> and change it to <complication debug=“false”>. In case you are of the curious types… take a plunge.


View Entire Article

User Comments

Title: NIKE NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:11:27 AM
Comment:
http://www.jersey2shop.com
http://www.cheapjersey2store.com
http://www.jerseycaptain.com
http://www.yourjerseyhome.com
We are professional jerseys manufacturer from china,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
Cheap NFL,NBA,MLB,NHL
,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,wholesal.cheap nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes. www.yourjerseyhome.com
Title: SS   
Name: SS
Date: 2010-10-03 7:34:45 AM
Comment:
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
Comment:
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
Comment:
.
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
Comment:
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
Comment:
Superb Article !!!!!!!!Great Explanation Rahul.
Title: For Gurpiar Singh   
Name: Rahul Soni
Date: 2008-08-01 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: 2008-08-01 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: 2008-05-12 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: 2007-08-22 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: 2007-08-22 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: 2007-08-21 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: 2007-08-21 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: 2007-08-18 5:01:36 AM
Comment:
Great article!!!
Title: The Infamous Debug=True Attribute in ASP.NET   
Name: Sojesh
Date: 2007-08-15 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: 2007-08-02 6:19:00 AM
Comment:
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
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-2017 ASPAlliance.com  |  Page Processed at 2017-04-25 12:44:09 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search