Web Site Deployment in Visual Web Developer
After developing a Web site, you can deploy it to a Web server for testing (a staging server) or to a server where users can work with the site (a production server). Visual Studio 2005 provides the following options for deploying your site:
The Copy Web Site tool, which copies the current Web site directly to the target server.
The Publish Web Site utility, which compiles your Web site into a set of executable files. You can then copy the files using any method you choose to the target server.
The Publish Web Site utility is not available in Visual Web Developer Express Edition.
In addition to creating your Web site and then deploying it to a target server, you can also create a File Transfer Protocol (FTP) Web site. In this case, you create and edit the files directly on the target server, which is a convenient way to work with a Web site on a hosted server. For details, see.
Copy Web Site Tool
The Copy Web Site tool is similar to an FTP utility — you can open a folder on a target server, and then upload and download files between the current Web site and the target Web site. The Copy Web Site tool also supports a synchronization feature that examines the files in both Web sites and automatically makes sure that both sites have up-to-date versions of the files.
For details, see.
Publish Web Site Utility
The Publish Web Site utility precompiles the content of your Web site, including Web pages (.aspx files) and code, and copies the output to a directory or server location that you specify. You can publish directly as part of the precompilation process, or precompile locally and then copy the files yourself. The Publish Web Site utility compiles the Web site and strips the source code out of the files, leaving only stub files for the pages and compiled assemblies. When users request pages, ASP.NET fulfills the request from the precompiled assemblies. For details, see.
Choosing a Deployment Tool
Whether you choose the Copy Web Site tool and the Publish Web Site utility depends on how you intend to use and maintain your site.
Choosing the Copy Web Site Tool
Advantages of using Copy Web Site tool:
Deployment is a simple matter of copying files from your Web site to the target computer.
You can deploy to a target computer using any connection protocol that is supported by Visual Web Developer. You can use a UNC to copy to a shared folder on another computer on your network; use FTP to copy to a server; or use HTTP protocol to copy to a server that supports FrontPage Server Extensions.
You can make changes or fix errors in the pages directly on the server, if necessary.
If you are working with a project where files are stored in a central server, you can use the synchronize feature to be sure that the local and remote versions of files are synchronized.
Disadvantage of using the Copy Web Site tool:
The site is copied as-is. Therefore, if your files contain a compilation error, the error will not be discovered until someone (perhaps a user) runs the page that raises the error.
Choosing the Publish Web Site Utility
Advantages of using Publish Web Site utility:
The precompilation process helps you find compile-time errors and potential errors in the Web.config file and other non-code files.
The source code is removed from the Web site, including the markup in the .aspx files. This provides you with a measure of protection for your intellectual property and makes it more difficult for others to access the source code of your site.
Because the pages in the site are already compiled, they do not need to be dynamically compiled when first requested. This can reduce the initial response time for a page. (When pages are dynamically compiled, the output is cached for subsequent requests.)
Disadvantages of using the Publish Web Site utility:
Depending on what publish options you specify, you might need to recompile the site if you make changes to it. Therefore, it might not be practical to use the Publish Web Site utility while you are developing a site and changing pages frequently.
The Publish Web Site utility cannot deploy the compiled site to a remote server; it can copy only to your local computer or to another computer on your local area network.
The Publish Web Site utility overwrites files in the target folder, including subfolders. Be sure you publish to a location where it is safe to delete the existing contents.