IISConsider the scenario where you have developed a Web application and it is ready to be made available to the user. To enable the user to access the application, the Web application needs to be deployed on a Web server, such as IIS.

IIS is a Web server that provides a comprehensive platform, which helps you develop, host, and manage Web applications. IIS is a proprietary of Microsoft and is packaged along with the Windows operating system. By default, IIS is turned off when Windows is installed. Therefore, before deploying an application on IIS, you need to configure IIS on the Windows operating system.

Instead of using a deployment package, you can directly deploy a website to a target server, such as:

  • The IIS server on your development computer
  • An IIS server on your network
  • A server owned by a service provider
  • Windows Azure

For deploying a Web application on any of the preceding target servers, you can use the Publish Web wizard. While using the Publish Web wizards, you need to perform the following tasks:

  1. Create a publish profile.
  2. Configure the connection settings.
  3. Configure the publish and database settings.
  4. Publish the project.
Creating a Publish Profile

The first step to deploy a Web application is to configure a publish profile. A publish profile represents various deployment options, such as:

  • The target server to be used for deployment
  • The credentials needed to log on to the server
  • The databases to deploy

If you are deploying your Web application to Windows Azure or a target server owned by a service provider, the service provider will provide you a .publishsettings file. You can automatically create the publish profile by importing this .publishsettings file while using the Publish Web wizard.

Configuring the Connection Settings

After creating a publish profile, you need to configure the connection settings. The first step for this is to select a publish method. Some publish methods that can be used are:

  • File System: This method publishes the Web application in a folder that you specify. This option can be used for servers to which you have direct network access. You can also use this option to first publish a Web application to a local folder, and then copy the files to the target server.
  • Web Deploy: This method allows you to specify database settings, such as connection strings. These settings will override the settings in the Web.config file of the application, and a new version of the Web.config file will be created for the target environment. Web Deploy also helps you to automatically update the schema of the database.

Once you have selected a publish method, you need to specify the connection details of the target server.

Configuring the Publish and Database Settings

After specifying the connection settings, you need to specify the publish and database settings. For example, you can specify whether to use the release or debug build configuration. While deploying a Web application, you normally use a release build. The debug build is not efficient and is used only when you are deploying to a test environment, where debugging may be required.

In addition to specifying the build configuration, you can also specify various file publish options such as:

  • Whether to remove files on the destination server that have no matching files in the Web application on your development computer.
  • Whether to precompile the project before publishing.
  • Whether to prevent the files in the App_Data folder from being deployed on the target server.

Further, you need to specify the connection strings to the target database servers that your application needs to use after deployment. In addition, you can specify whether to run code first migrations on application start.

Publishing the Project

Once all the settings are done, you can use an option available in the Publish Web wizard to preview the files that will be copied to the target server. After ensuring that the correct files are being copied, you can publish the project.

Creating and Installing a Deployment Package

To deploy a Web application on a Web server, you can create a deployment package. You can use the Publish Web wizard to configure one or more publish profiles for creating a deployment package. A publish profile represents the deployment options, such as the server on which you want to deploy a Web application and the databases that are required to be deployed.

Once you have created a deployment package, you can install the package on the destination server by using the <projectname>.deploy.cmd file that Visual Studio creates with the package.