Deploy ASP.NET to a remote IIS computer using Web Deploy in Visual Studio

This article explains how to set up and configure a Visual Studio 2017 ASP.NET MVC 4.5.2 application and deploy it to IIS. This article includes steps on setting up a basic configuration of IIS on Windows server and deploying the app from Visual Studio. These steps are included to make sure that the server has required components installed and that you are ready to deploy. If you are deploying an ASP.NET Core application, some steps are different. To deploy an ASP.NET Core app, see Publish an application to IIS by importing publish settings for instructions. In some ASP.NET and ASP.NET Core scenarios, it is faster to deploy to IIS by importing publish settings.

These procedures have been tested on these server configurations:

  • Windows Server 2012 R2 and IIS 8 (For Windows Server 2008 R2, the server steps are different)

Create the ASP.NET 4.5.2 application on the Visual Studio computer

  1. On the computer running Visual Studio, choose File > New Project.

  2. Under Visual C# or Visual Basic, choose Web, and then in the middle pane choose either ASP.NET Web Application (.NET Framework) and then click OK.

    If you don't see the specified project templates, click the Open Visual Studio Installer link in the left pane of the New Project dialog box. The Visual Studio Installer launches. See the prerequisites in this article to identify the required Visual Studio workloads, which you must install.

  3. Choose MVC (.NET Framework) and make sure that No Authentication is selected, and then click OK.

  4. Type a name like MyWebApp and click OK.

    Visual Studio creates the project.

  5. Choose Build > Build Solution to build the project.

Install and configure IIS on Windows Server

These steps show only a basic configuration of IIS. For more in-depth information or to install to a Windows Desktop machine, see Publishing to IIS or IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5.

For Windows Server operating systems, use the Add Roles and Features wizard via the Manage link or the Dashboard link in Server Manager. On the Server Roles step, check the box for Web Server (IIS).

The Web Server IIS role is selected in the Select server roles step.

On the Role services step, select the IIS role services you desire or accept the default role services provided. If you want to enable deployment using publish settings and Web Deploy, make sure that IIS Management Scripts and Tools is selected.

Proceed through the confirmation steps to install the web server role and services. A server/IIS restart is not required after installing the Web Server (IIS) role.

Update browser security settings on Windows Server

If Enhanced Security Configuration is enabled in Internet Explorer (it is enabled by default), then you may need to add some domains as trusted sites to enable you to download some of the web server components. Add the trusted sites by going to Internet Options > Security > Trusted Sites > Sites. Add the following domains.


When you download the software, you may get requests to grant permission to load various web site scripts and resources. Some of these resources are not required, but to simplify the process, click Add when prompted.

Install ASP.NET 4.5 on Windows Server

If you want more detailed information to install ASP.NET on IIS, see IIS 8.0 using ASP.NET 3.5 and ASP.NET 4.5.

  1. In the left pane of Server Manager, select IIS. Right-click the server and select Internet Information Services (IIS) Manager.

  2. Use the Web Platform Installer (WebPI) to install ASP.NET 4.5 (from the Server node in Windows Server 2012 R2, choose Get New Web Platform Components and then search for ASP.NET)



    If you are using Windows Server 2008 R2, install ASP.NET 4 instead using this command:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir

  3. Restart the system (or execute net stop was /y followed by net start w3svc from a command prompt to pick up a change to the system PATH).

Install Web Deploy 3.6 on Windows Server

  1. If you intend to deploy your applications with Web Deploy in Visual Studio, install the latest version of Web Deploy on the server.

    To install Web Deploy, use the Web Platform Installer (WebPI). (To find the Web Platform Installer link from IIS, select IIS in the left pane of Server Manager. Right-click the server and select Internet Information Services (IIS) Manager.)

    In the Web Platform Installer, you find Web Deploy in the Applications tab. You can also obtain an installer directly from the Microsoft Download Center.

  2. Verify that Web Deploy is running correctly by opening Control Panel > System and Security > Administrative Tools > Services and make sure that Web Deployment Agent Service is running (the service name is different in older versions).

    If the agent service is not running, start it. If it is not present at all, go to Control Panel > Programs > Uninstall a program, find Microsoft Web Deploy . Choose to Change the installation and make sure that you choose Will be installed to the local hard drive for the Web Deploy components. Complete the change installation steps.

Configure ASP.NET Web site on the Windows Server computer

  1. Open Windows Explorer and create a new folder, C:\Publish, where you will later deploy the ASP.NET project.

  2. If it's not already open, open the Internet Information Services (IIS) Manager. (In the left pane of Server Manager, select IIS. Right-click the server and select Internet Information Services (IIS) Manager.)

  3. Under Connections in the left pane, go to Sites.

  4. Select the Default Web Site, choose Basic Settings, and set the Physical path to C:\Publish.

  5. Right-click the Default Web Site node and select Add Application.

  6. Set the Alias field to MyASPApp, accept the default Application Pool (DefaultAppPool), and set the Physical path to C:\Publish.

  7. Under Connections, select Application Pools. Open DefaultAppPool and set the Application pool field to ASP.NET v4.0 (ASP.NET 4.5 is not an option for the Application pool).

  8. With the site selected in the IIS Manager, choose Edit Permissions, and make sure that IUSR, IIS_IUSRS, or the user configured for the Application Pool is an authorized user with Read & Execute rights. If none of these users are present, add IUSR as a user with Read & Execute rights.

Publish and deploy the app using Web Deploy from Visual Studio

If you installed Web Deploy using the Web Platform Installer, you can deploy the app directly from Visual Studio.

  1. Start Visual Studio with Administrator privileges, and reopen the project.

    Administrator privileges are required to deploy your app using Web Deploy.

  2. In the Solution Explorer, right-click the project node and select Publish.

    If you have previously configured any publishing profiles, the Publish pane appears. Click New profile.

  3. For Select a publish target, select IIS, FTP, etc. and click Publish.


  4. Enter the correction configuration parameters for your IIS setup.


    If a host name doesn't resolve when you try to validate in the next steps in the Server text box, try the IP address. Include http:// as a prefix in the Server field. Make sure you use port 80 in the Server text box, and make sure that port 80 and port 8172 are open in the firewall.

  5. Choose Validate. If the connection setup validates, you can try to publish.

  6. Click Publish to publish the app.

    The Output tab shows you if publishing is successful, and your browser then opens the app.

    If you get an error mentioning Web Deploy, recheck the Web Deploy installation steps and make sure the correct ports are open (Web Deploy also requires port 8172 to be open on the server).

    If the app deploys successfully but doesn't run correctly, there may be an issue with your IIS configuration, your ASP.NET installation, or your Web site configuration. On the Windows Server, open the Web site from IIS for more specific error messages, and then recheck earlier steps.

Also, you may need to read the following section on how to troubleshoot ports.

Troubleshoot: Open required ports on Windows Server

In most setups, required ports are opened by the installation of ASP.NET and Web Deploy. However, you may need to verify that ports are open.


On an Azure VM, you must open ports through the Network security group.

Required ports:

  • 80 - Required for IIS
  • 8172 - Required for Web Deploy to deploy the app from Visual Studio
  1. To open a port on Windows Server, open the Start menu, search for Windows Firewall with Advanced Security.

  2. Then choose Inbound Rules > New Rule > Port. Choose Next and under Specific local ports, enter the port number, click Next, then Allow the Connection, click Next, and add the name (IIS, Web Deploy, or msvsmon) for the Inbound Rule.

    If you want more details on configuring Windows Firewall, see Configure the Windows Firewall for remote debugging.

  3. Create additional rules for the other required ports.

Next steps

In this tutorial, you created a publish settings file, imported it into Visual Studio, and deployed an ASP.NET app to IIS. You can also deploy by importing publish settings.