5. Deploy with an Appropriate Strategy
This article covers two main techniques for deploying your ASP.NET web sites: using the Copy Web Site Tool, and using XCOPY deployment. It also briefly touches on Click-Once deployment. The newer of the two main techniques is the Copy Web Site Tool, introduced in ASP.NET 2.0.
Deploying with the Copy Web Site Tool
The steps below show a complete example of copying one web site to another:
- Create a new web site called SourceWebSite by selecting File → New → Web Site in the Visual Studio as shown in Figure 2.
|Figure 2. Create New Web Site: Choose the standard ASP.NET Web Site template from the New Web Site dialog.|
|Figure 3. Copy Web Site: Right-click on the source web site in Solution Explorer and choose Copy Web Site from the context menu.|
- Following the same steps, create another web site called SharedWebSite. You'll copy this web site to the SourceWebSite using the Copy Web Site tool.
- Now, select the SourceWebSite in the Visual Studio Solution Explorer, right click on it and select the Copy Web Site option (see Figure 3).
- Optionally, you can also select the SourceWebSite and click on the Copy Web Site option in the solution explorer as shown in Figure 4.
|Figure 4. Quick Web Site Copy: Select the source web site and click the Copy Web Site Option button in the Solution Explorer toolbar.|
|Figure 5. Open Web Site Dialog: Select the shared/remote web site and click Open.|
- You'll see the Copy Web Site screen. You'll see the files from your source web site listed in the left pane.
- Select the shared web site (your remote web site).
When you do so, the Open Web Site dialog pops up; select the shared/remote web site and click the Open button (see Figure 5).
- The next screen shows all the files of the shared/remote web site listed in the right pane. Select all the files listed in the Remote Web Site pane as shown in Figure 6.
|Figure 6. Selecting Remote/Shared Files: Select all the files from the remote/shared site in the right-hand pane.|
|Figure 7. Copy Files: Copy selected files between the remote/shared web site and your local web site using the Copy button.|
- Now, click on the Copy Selected Files option button to copy the files from the shared/remote web site to your local web site (see Figure 7).
If the copy process finds file conflicts, it prompts you to confirm whether or not the file(s) should be overwritten (see Figure 8
|Figure 8. File Conflict Resolution: When file conflicts occur, you'll get a chance to decide how the copy process should resolve the conflict.|
If the sites have identically-named subfolders, you can easily synchronize the source and remote web sites by selecting the "Synchronize Files" option as shown in Figure 9
|Figure 9. Synchronize Files: Clicking this button synchronizes selected files between the remote and local servers for files in matching paths.|
That completes the Copy Web Site process.