ASP.NET changes the way you handle compilation and deployment from what you might be used to from working with ASP.NET 1.1. Rick Strahl wrote an excellent article
that describes the nuances in great detail. Check out his article for
the step-by-step process, but at a high level there are a few facts you
should be aware of when you are ready to deploy your ASP.NET 2.0
applications.
You may choose to deploy your web application to the server using one of three general options:
Note: There are more than three options, but this is a quick reference, so you are just getting the basic differences.
Pre-compiled: Allow Updates to ASPX
When you
choose to pre-compile your website you have the option to allow updates
to your ASPX files. If you choose to allow these updates DLLs are
created for the code behind files in your web project. These files are
generated with a random name and the publish feature will update your
ASPX files to point the Inherits attribute to the appropriate DLL
(which houses your namespace and class for each page).
Pre-compiled: Restrict Updates to ASPX
If you
choose to pre-compile and not allow updates to your ASPX pages, all of
your code (including HTML) is compiled into the DLL and the physical
ASPX is placed on the web server as a marker, holding no markup or code
whatsoever.
Dynamic Compilation: Allow Updates to ASPX and CS/VB Files
For
reasons detailed below, you may choose to simply copy ASPX and CS/VB
code behind files up to the web server in the same manner as they exist
on your development machine. When the first user to hit a page arrives,
the web server will compile the code for that page and allow execution
throughout the site. The performance penalty is negligible as the
compilation is only for that single page and only for the first user to
hit the page.
Which Option is Best?
As always the answer is dependent upon your circumstances.
- Pre-compilation allowing updates garners a performance gain, but
forces you to re-deploy all of your ASPX files to the server when a
change is made to ANY codebehind in the website.
- Pre-compilation restricting updates gives you an even further
performance gain, but you will not be able to add non-server processed
updates to a web page without having to recompile.
- Dynamic compilation is the easiest to maintain, but results in
slightly lower performance and a potential security risk of your source
files living on the web server.
Hopefully this helps you as you begin working with ASP.NET 2.0
website. Like I said this is just a quick reference, be sure to do your
homework for the details.
I am often asked how listeners can support the Polymorphic Podcast. One of the best (and most valuable) ways to show your support is to simply tell others about what you like!
As my way of saying thanks for your endorsement, you can win a free
copy of "Beginning Ajax with ASP.NET" by simply telling others. Just
send an email telling someone about the show (be sure to CC
show{at}polymorphicpodcast{dot}com), or better yet enter a blog post
with a link back to http://polymorphicpodcast.com/ and you are in the running!
(If you choose to do a blog post, please be sure to send me an email
at show{at}polymorphicpodcast{dot}com. Yes I will pick up the
post in my blog search aggregations, but I want to be fair to
those who know about the book offer.)
I will pick two winners at random from emails and two winners at
random from blog posts. The winnners will be annouced on the first show
in November on the Polymorphic Podcast.
Thanks!
Craig