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
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.