Condividi tramite


ASP.NET Web Site Project Deployment Overview

After you have created an ASP.NET Web site project in Visual Studio, you typically deploy the project to a Web server where others can access your application. Deployment typically involves more than just copying the application's files from one server to another. You might also have to perform additional tasks such as the following:

  • Changing Web.config settings that must be different in the destination environment.

  • Propagating data or data structures in databases that are used by the Web application.

  • Configuring IIS settings on the target computer, such as the application pool, the authentication method, whether directory browsing is allowed, and error handling.

  • Installing security certificates.

  • Setting values in the registry of the target computer.

  • Installing application assemblies in the GAC on the target computer. (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. For more information, see Global Assembly Cache.)

This topic describes the tools that are available to perform the file-copying part of deploying Web site projects and explains how to use them. Most of the other tasks must be done manually. For information about other deployment tasks, see Web Deployment Content Map for Visual Studio and ASP.NET.

Note

This topic applies only to Web site projects. For information about the difference between Web application projects and Web site projects, see Web Application Projects versus Web Site Projects in Visual Studio.

This topic contains the following sections.

  • Tools for Deploying Web Site Projects
  • The Copy Web Site Tool
  • The Publish Web Site Tool
  • Choosing a Deployment Tool
  • Related Topics

Tools for Deploying Web Site Projects

For the part of Web site project deployment that involves copying files, you can use general purpose tools such as Windows Explorer, the Windows xcopy command, or an FTP tool. Visual Studio provides the following specialized tools that help to automate the process of copying files and can precompile a Web site project as part of the deployment process:

  • The Copy Web Site tool helps to automate the process of copying and synchronizing files between the Web site project that you have open and another site.

  • The Publish Web Site tool compiles some source code files into assemblies and then copies those assemblies and other required files to a folder that you specify. You can then use whatever method you prefer to copy the files to a different server.

    Note

    The Publish Web Site tool is not available in Visual Web Developer Express.

As an alternative to these tools, you can open a Web site directly on the Web server by opening it as a Visual Studio FTP Web site project. In that case, you can work with files directly on the live site. However, opening a site by using FTP can be slower than working with files offline. In addition, when you update live files in a site, they are live immediately before you have a chance to test them, and you might introduce errors that your users can see.

None of the options copy the Machine.config file or the root Web.config file. Some of the settings in these files are inherited by your Web site. Therefore, the configuration of your site when it runs on the target Web server might differ from its configuration on your computer. This might affect the behavior of the application.

The Copy Web Site Tool

The Copy Web Site tool enables you to open a folder on a target site (which can be on a remote computer or just a different folder on the same computer), and then copy files between the source Web site and the target Web site. The tool supports the following features:

  • You can copy source files, including.aspx files and class files, to the target site. The Web pages are compiled dynamically when they are requested on the target server.

  • You can copy files by using any connection protocol that is supported by Visual Studio. This includes local Internet Information Services (IIS), Remote IIS, and FTP. If you use HTTP protocol, the target server must have FrontPage Server Extensions.

  • The synchronization feature examines the files in the source and target Web sites, informs you about which files are more current in each site, and enables you choose which files you want to copy and the direction in which you want to copy them.

  • Before you copy application files, the Copy Web Site tool puts a file that is named App_offline.htm into the root directory of the target Web site. While the App_offline.htm file exists, any requests to the Web site are redirected to this file. The file displays a friendly message that tells clients that the Web site is being updated. When all Web site files have been copied, the Copy Web Site tool deletes the App_offline.htm file from the target Web site.

The Publish Web Site Tool

The Publish Web Site tool precompiles the content of the Web site and then copies the output to a directory or server location that you specify. You can write the output to any folder that is available to you in the local or internal network file system, by using File Transfer Protocol (FTP), or by using HTTP. You must have appropriate permissions to be able to write to the target site.

You can publish directly to a Web server as part of the publish process, or you can precompile to a local folder and then copy the files to a Web server yourself.

For more information about precompilation, see ASP.NET Web Site Project Precompilation Overview.

Choosing a Deployment Tool

Whether you select the Copy Web Site tool or the Publish Web Site tool depends on how you intend to use and maintain your site.

Use the Copy Web Site tool in the following situations:

  • You make frequent changes to the site and you don't want to have to manually compile the site every time you make a change.

  • You want to use the tool's synchronization feature and you want to deploy the site to a remote Web server by using FTP or HTTP. (The Publish Web Site tool can copy only to the local computer or to another computer on the local network.

  • You do not need to precompile the site.

Use the Publish Web Site tool in the following situations:

  • You want to precompile the site in order to avoid putting source code or markup on the Web server. This helps to protect your intellectual property.

  • You want to precompile in order to avoid the delay caused by dynamic compilation the first time a page is requested from the Web server. (You should test the site to determine if this delay is significant before deciding that precompiling the site is worthwhile for this reason.)

See Also

Tasks

How to: Deploy Web Projects Targeted for Earlier Versions of the .NET Framework

Concepts

ASP.NET Web Site Project Precompilation Overview

ASP.NET Side-by-Side Execution Overview

Other Resources

Web Deployment Content Map for Visual Studio and ASP.NET