What's New in Publishing Web Sites in Visual Studio
This topic describes the new features in Visual Studio for deploying, or publishing, Web sites to a staging or production server.
Visual Studio 2005 makes the process of moving a development Web site to a staging or production server significantly easier than it was in earlier versions. In earlier versions, you would build all of the code portions of your Web site into a single assembly. You would then deploy the built assembly along with the .aspx files, the Web.config file, and other non-code files to the target server. The primary ways to deploy the files were by using the Copy Project utility, which required the target server to be available on a local area network; by using FrontPage Server Extensions from Microsoft; or by creating a setup project to generate an installation (.msi) file.
In the current version of Visual Studio, you can deploy a project by using the following tools:
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 to the target server, using any method that you choose.
The Publish Web Site utility is not available in Visual Web Developer Express Edition.
These tools do not require special configuration on the target server, such as FrontPage Server Extensions.
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.
Copying Web Sites
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 has the following improvements over the Copy Project utility in earlier versions of Visual Studio:
You do not need to compile the files in your Web site before copying them to the target server. Instead, you can simply copy the source files, including the .aspx files and class files, to the target server. As with any ASP.NET Web site, the Web pages are compiled dynamically when requested.
The Copy Web Site tool enables you to open and copy files from any type of Web site that is supported in Visual Studio, including local Internet Information Services (IIS), Remote IIS, and FTP. The target server does not require FrontPage Server Extensions.
The Copy Web Site tool also does more than just copy a project to a target server. It 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.
Before copying your application files, the Copy Web Site tool places a file called App_offline.htm to the root directory of the target Web site. While the App_offline.htm file exists, any request to the Web site will redirect to this file, which displays a friendly message informing clients that the Web site is being updated. When the all of the Web site files have been copied, the Copy Web Site tool deletes the App_offline.htm file from the target Web site.
For details, see.
You must have the .NET Framework version 2.0 installed on the target server for your Web pages to run as expected.
If the target server is an FTP server, you can open and edit the files on the server by creating an FTP Web site. You can also administer the target site using the Web Site Administration Tool. For details, see.
Compiling Web Sites
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.
The precompilation process used in the Publish Web Site utility differs from the compilation process in earlier versions of Visual Studio in the following ways:
In Visual Studio .NET 2003, only the code files were compiled. In the Publish Web Site utility, you can optionally compile markup in .aspx files along with page code and any other executable files.
Visual Studio .NET 2003 compiled all code into a single assembly. In the newer model, all standalone class files are compiled into one assembly. However, pages and their corresponding code (whether single-file or code-behind) are compiled into individual assemblies.
In the Publish Web Site utility, source code is removed from the Web site, including optionally the markup in .aspx files. The .aspx files are still there, but they contain only pointers to the compiled versions of the pages. This provides a measure of protection for your intellectual property and makes it more difficult for others to access the source code of your site.
The end result is a Web site that has the same advantages as the compiled output created by earlier versions of Visual Studio, including quicker initial response times for pages and precompilation to help you discover compile-time errors in code. The Publish Web Site utility also compiles non-code files, such as the Web.config file. This means that it can help you find compilation errors as well as problems with the configuration file.
For more information, see.