Deploying ASP.NET 2.0 websites
2009 Jan 2, Information Technology
There are three main approaches to deploying ASP.NET 2.0 websites. (ASP.NET 3.5 is not much different, if at all.)
For more information, especially with regard to the pros and cons of each approach, please see the excellent MSDN article titled "Selecting a Precompilation Model".
Let's illustrate with sample solution Website1:

Website1 consists of two web pages, Default.aspx and OtherPage.aspx, plus two classes in the App_Code directory.
Here are the three deployment approaches:
1. Copy the solution, as is, to the website deployment directory.
In Visual Studio 2005, you can use the Website | Copy Website menu item to accomplish this. When the first request comes in, ASP.NET will compile the website on the fly. The deployment directory (IIS virtual path) will be organized completely consistent with the (Visual Studio 2005) Solution Explorer view above:


2. Copy the solution, as is, to the website deployment directory, then compile it there ("in place").
This approach is just a matter of taking the first deployment approach one step further. After copying the solution to the deployment directory, instead of waiting for the first request to come in, compile the website manually via the ASP.NET Compilation Tool (Aspnet_compiler.exe). This ensures that the first request, whenever it comes, does not experience a slow response due to the overhead of compilation.
Note that this approach has no effect on the website as it appears in the deployment directory. The assemblies generated are written to a temporary folder, from which IIS accesses them.
The "in place" compilation command for Website1 is as simple as this:
Aspnet_compiler -v /WebSite1
Enter it from the Visual Studio command prompt as shown here:

3. Precompile the solution for deployment.
In Visual Studio 2005, you can use the Build | Publish Web Site menu item to accomplish this.
The Publish Web Site interface offers three options, via checkboxes, for publishing a solution. Here we will look at only the first two:
a) "Allow this site to be updateable"
b) "Use fixed naming and single page assemblies"
The organization of your published website depends on how you set these checkboxes. Here is a summary showing the differences, using our Website1 solution from above:
"Allow this site to be updateable" - Checked
"Use fixed naming and single page assemblies" - Not Checked
Class1.vb and Class2.vb are compiled into a single App_Code.dll assembly.
App_Code.compiled is an XML file that associates Class1.vb and Class2.vb with App_Code.dll.
Default.aspx.vb and OtherPage.aspx.vb are compiled into App_Web_[gibberish].dll, but the markup in Default.aspx and OtherPage.aspx remains as is (since it is updateable).


"Allow this site to be updateable" - Not Checked
"Use fixed naming and single page assemblies" - Not Checked
Class1.vb and Class2.vb are compiled into a single App_Code.dll assembly.
App_Code.compiled is an XML file that associates Class1.vb and Class2.vb with App_Code.dll.
Default.aspx and OtherPage.aspx, markup and all, are compiled into App_Web_[gibberish].dll.
Since it is not updateable, the markup in Default.aspx and OtherPage.aspx is replaced with this warning:
"This is a marker file generated by the precompilation tool, and should not be deleted!"
default.aspx.[gibberish].compiled and otherpage.aspx.[gibberish].compiled are XML files that associate Default.aspx and OtherPage.aspx with App_Web_[gibberish].dll.
Here we show only the bin directory, as the main directory looks the same in each of these cases:

"Allow this site to be updateable" - Checked
"Use fixed naming and single page assemblies" - Checked
Class1.vb and Class2.vb are compiled into a single App_Code.dll assembly.
App_Code.compiled is an XML file that associates Class1.vb and Class2.vb with App_Code.dll.
The markup in Default.aspx and OtherPage.aspx remains as is (since it is updateable).
Default.aspx.vb and OtherPage.aspx.vb are compiled into separate assemblies App_Web_default.aspx.[gibberish].dll and App_Web_otherpage.aspx.[gibberish].dll.

"Allow this site to be updateable" - Not Checked
"Use fixed naming and single page assemblies" - Checked
Class1.vb and Class2.vb are compiled into a single App_Code.dll assembly.
App_Code.compiled is an XML file that associates Class1.vb and Class2.vb with App_Code.dll.
Default.aspx and OtherPage.aspx, markup and all, are compiled into separate assemblies App_Web_default.aspx.[gibberish].dll and App_Web_otherpage.aspx.[gibberish].dll.
Since it is not updateable, the markup in Default.aspx and OtherPage.aspx is replaced with this warning:
"This is a marker file generated by the precompilation tool, and should not be deleted!"
default.aspx.[gibberish].compiled and otherpage.aspx.[gibberish].compiled are XML files that associate Default.aspx and OtherPage.aspx with App_Web_default.aspx.[gibberish].dll and App_Web_otherpage.aspx.[gibberish].dll.
