Share via


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 .NET Framework Deployment Basics.

NoteNote

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 ASP.NET Compilation Tool (Aspnet_compiler.exe).

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.

For more information, see Global Assembly Cache. For more information about assemblies, see Programming with Assemblies.

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: Publishing a Web Site and Walkthrough: Deploying a Web Site Project by Using the Publish Web Site Tool.

Prerequisites

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 How to: Create and Configure Virtual Directories in IIS.

  • A destination that is accessible using a file path or UNC path.

NoteNote

This walkthrough does not assume that you are using a designer, such as Visual Web Developer or Visual Studio.

Preparation

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

  1. Create a file called App_offline.htm and place it in the root of your target Web site.

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

    NoteImportant

    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

  1. 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="https://schemas.microsoft.com/.NetConfiguration/v2.0">
      <system.web>
      </system.web>
    </configuration>
    

    For more information, see ASP.NET Configuration Files.

  2. Add an httpRuntime Element (ASP.NET Settings Schema) element 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="https://schemas.microsoft.com/.NetConfiguration/v2.0">
      <system.web>
        <httpRuntime       waitChangeNotification="5"    />
      </system.web>
    </configuration>
    
  3. 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="https://schemas.microsoft.com/.NetConfiguration/v2.0">
      <system.web>
        <httpRuntime 
          waitChangeNotification="5"
          maxWaitChangeNotification="10"
        />
      </system.web>
    </configuration>
    

To deploy an ASP.NET Web application using XCOPY from the command line

To deploy or update individual files in an ASP.NET Web application from the command line

See Also

Tasks

Walkthrough: Developing and Using a Custom Server Control
Walkthrough: Creating an ASP.NET Web Application Root Directory with IIS

Concepts

ASP.NET Web Site Layout
XML Web Services Publishing and Deployment

Other Resources

ASP.NET Web Applications
Deploying Applications