Ibahagi sa


How to: Publish Web Application Projects

You can publish ASP.NET Web application projects using Visual Studio or Visual Web Developer Express. When you publish an ASP.NET Web application project, Visual Studio or Visual Web Developer Express compiles the Web application files into a single assembly and then copies the compiled assembly to a specified location. Web application projects share the configuration settings and behavior that are used for standard Visual Studio 2010 class-library projects. You can publish the Web application to a local or shared folder, to an FTP site, or to a Web site that you access by using a URL.

The Publish Web dialog box, which you can access from the Visual Studio or Visual Web Developer Express** Build** menu, enables you to build and publish Web applications. When you publish the site, you can remove source code from the site. 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. For information about what occurs to files during precompilation, see File Handling During ASP.NET Precompilation.

Note

The Publish Web dialog box applies only to projects that are created by using the ASP.NET Web Application template.

Before you publish the Web application, check the configuration of your original site and take note the following:

  • Any settings that must exist at the remote location. Review settings such as connection strings, membership settings, and other security settings, and make sure that these settings are appropriate for the production environment.

  • Any settings that must be changed for the published Web site. For example, you typically disable debugging, tracing, and custom errors after you publish the Web site.

Because configuration settings are inherited, you might have to examine multiple files to find all applicable settings. Configuration settings can be located in the Machine.config file or the root Web.config file in the SystemRoot\Microsoft.NET\Framework\version\CONFIG directory, and in Web.config files in your application. If you do not have permission to view the root configuration files, you can create a complete list of configuration settings for the Web site, formatted as a configuration file. For more information, see How to: View Inherited and Local Configuration Settings Programmatically. For definitions of configuration settings, see General Configuration Settings (ASP.NET) and ASP.NET Configuration Settings.

Note

To complete the following procedure, you must have both Create and Write permissions in the target location.

To publish a Web application project

  1. In the Build menu, click Publish ProjectName.

    The Publish Web dialog box is displayed.

  2. Click the ellipsis button () to browse to the location that you want to publish the Web application project to.

  3. Select the Replace matching files with local copies check box or the Delete all existing files prior to publish check box.

  4. Select how you want to copy the Web application project files to the new location by using Only files needed to run this application, All project files, or All files in the source project folder.

    You can include files from the App_Data folder by selecting the corresponding check box.

  5. Click OK to publish the Web application project.

    In the task bar, Publish succeeded is displayed when publishing has finished.

  6. Make any configuration changes that are required for the Web application at the target location.

    For more information, see How to: Configure Published Web Site Projects.

    Note

    To help increase security, you might want to encrypt specific configuration settings. For more information, see Encrypting Configuration Information Using Protected Configuration.

See Also

Reference

Publish Web Dialog Box

Concepts

ASP.NET Web Application Projects