Posted by
Al Nyveldt in
Development on Apr 04, 2006 |
0 responses
One of the interesting features of ASP.NET 2.0 is the fact that
the site, by default, is dynamically compiled and managed by the
ASP.NET runtime. The standard method I've read most about for
installing your web site is to just copy your code and assemblies to
your web server and let the runtime handle the rest. If you need to
update a page or class, just update the file and the ASP.NET runtime
will handle the update for you.
However, you can also precompile your sites to protect your code and to
avoid the first hit compile delay (which was negligable for me in my
testing). Interestingly, I was unable to find a way to do it inside
Visual Studio 2005. It is done from the command line. The command is
aspnet_compiler and it is in your 2.0 framework folder
(C:\Windows\Microsoft.NET\Framework\v2.0.xxxxx). You run it with the
-v virtualPath and a targetPath.
aspnet_compiler -v /samplesite c:\temp\samplesite
This will compile all your code into assemblies and place them in your target (c:\temp\samplesite).
Upon inspecting your compiled code, you notice that all the aspx pages
are still there, but they are all 1 KB in size. All the code files are
gone and replaced with dll files in the bin folder.
The 1 KB aspx files all contain the following text:
This is a marker file generated by the precompilation tool, and should not be deleted!
I thought it was pretty cool that all the code in the aspx files was compiled as well and removed.