|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Walkthrough: Deploying an ASP.NET Web Application Using XCOPY
Deploying ASP.NET applications is very straightforward. You need to copy the application files you have created from your development computer to the production Web server that will host your application. You can use the XCOPY command-line tool or your preferred FTP application to copy the files from one location to another. For more information about general deployment, see.
As an alternative to using the XCOPY command-line tool, which is supported by all versions of the .NET Framework, you can use the new .NET Framework 2.0 tool located at %SystemRoot%\Microsoft.NET\Framework\version 2 or later\Aspnet_compiler.exe to compile and deploy your Web application. For more information, see.
Assemblies that you want to share across Web applications, such as assemblies that contain custom ASP.NET server controls, should be deployed to the global assembly cache (GAC) on a remote server.
If you deploy an application that contains a reference to a custom component registered in the global assembly cache on the local server, the component will not be deployed with the application to the remote server. You will need to install the component in the global assembly cache on the remote server, or you can copy the custom component to the Bin folder of the local Web application before deployment.
Some development tools such as Visual Web Developer have tools that make it easy to deploy your applications. For more information, see Walkthrough: Publishing a Web Site and Walkthrough: Deploying a Web Site Project by Using the Publish Web Site Tool and Walkthrough: Publishing a Web Site and Walkthrough: Deploying a Web Site Project by Using the Publish Web Site Tool.
In order to complete this walkthrough, you need:
The .NET Framework.
An existing ASP.NET Web site. If you already have such a site configured, you can use that site as a starting point for this walkthrough. Otherwise, for details on creating a virtual directory or site, see.
A destination that is accessible using a file path or UNC path.
This walkthrough does not assume that you are using a designer, such as Visual Web Developer or Visual Studio.
Use these procedures if you are deploying a large Web site and you want to take the target Web site offline while you are copying files.
To take a Web application offline before deployment
Create a file called App_offline.htm and place it in the root of your target Web site.
Put a friendly message in the App_offline.htm file to let clients know that you are updating the site.
While the App_offline.htm file exists, any request to the Web site will redirect to the file.
Remember to remove the App_offline.htm file after you are finished copying files.
When changes occur to some file types and folders, the application domain restarts. You can configure the number of seconds that the application waits for another file change notification before restarting the application domain.
To minimize the number of times your application domain restarts
Open the Web.config file for you Web application. If you do not have a Web.config file, you can create one using the following code.
<?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> </system.web> </configuration>
For more information, see.
Add anelement to your Web.config file and set the waitChangeNotification attributes to any number of seconds that exceeds the time between the updates of two file-copy change notifications. For example, your httpRuntime element might look like the following code.
<?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <httpRuntime waitChangeNotification="5" /> </system.web> </configuration>
Add a maxWaitChangeNotification attribute to your httpRuntime element and set it to the maximum number of seconds to wait from the first file change notification before restarting the application domain. Set it to a number that exceeds the length of time to complete any file copy processes. File-change notifications are combined based on the value of this attribute and the waitChangeNotification attribute. For example, your httpRuntime element might look like the following code.
<?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <httpRuntime waitChangeNotification="5" maxWaitChangeNotification="10" /> </system.web> </configuration>