How to: Prepare to Deploy a Web Project

Before you deploy or redeploy a Web project, you might want to prevent the production site from responding to page requests during the deployment process. This can help avoid errors that might result during the time when the changes are only partially completed. Also, when changes occur to some file types and folders, the application domain restarts, and you might want to make sure that this does not happen multiple times.

To take a Web application offline before deployment

  1. Create a file called App_offline.htm and include a message in the file that lets users know that the site is unavailable because you are updating the site.

  2. Place the App_offline.htm file in the root folder of the target Web site.

    While the App_offline.htm file exists in the root of your Web site, any request to the Web site will redirect to that file.

    When you have finished deploying the site, remove the App_offline.htm file.

To minimize the number of times your application domain restarts

  1. Open the Web.config file for your Web application. If you do not have a Web.config file, you can create one by following these steps:

    1. In Solution Explorer, right-click the Web site name.

    2. Select Add New Item.

    3. Select the Web Configuration File template.

    4. Click Add.

    For more information about configuration files, see ASP.NET Configuration Files.

  2. If you expect to submit multiple copy commands and there might be a time interval between them, you might not want the application domain to restart between copy commands. To prevent a restart, configure the Web.config file to delay the application domain restart. Add an httpRuntime Element (ASP.NET Settings Schema) element to the Web.config file and set the waitChangeNotification attribute to the number of seconds to wait to ensure that the application domain does not restart between copy commands. For example, if you want to specify a five-second wait time, the httpRuntime element might look like the following example.

    <configuration>
      <system.web>
            <compilation debug="false" targetFramework="4.0" />
        <httpRuntime 
          waitChangeNotification="5" />
      </system.web>
    </configuration>
    
  3. If you want to ensure that the application domain restarts within a certain interval after the first copy command executes, add a maxWaitChangeNotification attribute to the httpRuntime element and set it to the maximum number of seconds to wait. For example, a Web.config file that has the httpRuntime element with both attributes might look like the following example.

    <configuration>
      <system.web>
        <httpRuntime 
          waitChangeNotification="5"
          maxWaitChangeNotification="10" />
      </system.web>
    </configuration>
    

See Also

Concepts

ASP.NET Deployment Content Map