Asp.Net MVC Publish with Web Deploy

Here we will learn how to publish / deploy mvc web application to iis server using web deploy in visual studio or use web deploy option in visual studio to deploy / publish mvc web application in server with example.

Publish Site using Web Deploy in Visual Studio

In visual studio 2012 we have One-Click publish options by using those options we can deploy / publish mvc web application to iis or server directly from visual studio. We have different type of publish options available in visual studio 2012 in that one of option is Web Deploy.


Here we will learn step by step process to deploy or publish mvc web application using Web Deploy option in visual studio. To publish and deploy application here we are going to use simple Internet Application which we already created for deployment with name [OrderApp] like as shown below. mvc sample application to deploy / publish using visual studio


Now let’s build this application and run. Following is the snapshot after running application. mvc web deploy application output


It is working fine. Now we have checked our application and its working fine now let’s publish this Application. Before starting to publish our Application just Run Visual studio as Administrator like as shown below.


Run Visual Studio As Administrator to Publish / Deploy Application

Publishing Application using Visual Studio

To publish application just right click on Project name [OrderApp] and a List of options will appear from that List select [Publish] options like as shown below


Right click project and select publish option to deploy application


After selecting Publish option a new dialog will pop up with name Publish Web like as shown below.


Publish web deploy dialog to deploy mvc web application


In this dialog it will first ask you to create a profile. If you have created profile already then you can select profile from Manage profile just click on Manage profile button a new small dialog box of Edit Web Publish Profiles will appear in that you can see your already created Profile.


Created Web Publish Profiles in Visual Studio Deployment


If you had proper look on Publish Web dialog box you will also find Import button. After clicking on Import button below dialog will appear in this dialog you can Import profile from Azure Website or you can Import from Publish profile file.


Import profile from windows azure website or from publish profile file


We are new to publish this application hence we are going to create a New Profile.

Creating New Profile (stage 1)

To create a New Profile just select [Select or Import a publish profile] dropdown after selecting a [New Profile] item will appear in dropdown list just select that.


Select New Profile from from Select or Import a Publish


After selecting a New Profile, a new dialog box will appear with name [New Profile] asking to enter Profile name.


Enter Profile Name to Create in Publish Web Dialog


Here we entered profile name as [OrderAppDeploy] you can enter profile name of your choice.


Entered Profile Name as OrderAppDeploy to Publish Application


After entering profile name just click on OK button then this process will move forward to next stage Connection setting.

Connection setting in Visual Studio (Stage 2)

Now we are going to select a way to publish our application for that we need to move to second step connection like as shown below


Select publish method to deploy application in visual studio


If we click on Publish method dropdown we can able to see the list of ways to publish an application. For details you can have a look on below snapshot which shows Publish method Items. From this option we are first going to choose Web Deploy option.


Select Web Deploy Options from Publish method in Visual Studio


Here we selected Web Deploy method then we need to provide Server name, Site name, Destination URL. If we enter all Publish settings, then this site will get deployed on the server which we entered details.


Here we are going to deploy application in local IIS server for that we need to enter details like as shown below


Server name - localhost


Site name - Default Web Site/OrderApp 


Destination URL - http://localhost/OrderAPP 


Once we enter all the details of server we want to deploy the application that will be like as shown below


Enter All Server Details to Publish Web Application in Web Deploy


After entering all the details to deploy application then click on Next button to Move Forward to next stage of deployment process.

Settings for Deploying Application (Stage 3)

In this Process it will ask for selecting Configuration we have 2 options for this


  1. Debug - Debug is used for debugging.
  2. Release Mode - Release is final deployment.

Here we are going to select Release mode.


File Publish options section


After Selecting Configuration we have File Publish options those like as shown below.


  • If we want to remove additional files at destination, then we need to select this option.
  • If we want to Precompile application during publishing, then we need to select this option.
  • If we want to exclude files from the App_Data folder then we need to select this option.

Here we selected 2 options of [File Publish options] that will be like as shown below


Select File Publish Options in Publish Web Dialog to Deploy Website

Configuring Database section

If we have remote connection string, then we need to configure from here for that just select browse button to set remote Connection string. After choosing this option we need to enter all the details of Sql server with Server name, Username and Password. Following is the snapshot which we entered all the details.


Configure Database Remote Connection to Publish Web Application


After completion of adding all database setting now click on OK button. Following is the snapshot after configuring database connection.


After configuring database connection string in publish web dialog


After entering all details related to destination Connection String Click on Next button to Move Forward to next stage of deployment process.

Preview Details (Stage 4)

In this preview section we get a chance to view what are the files of our application which are going to Publish. Here we have check and uncheck files option which will help us to remove (uncheck) files which we don’t want to publish.


In first deploy it will Preview all the files and on next deploy only the changes will be Previewed. Following is the snapshot of Preview dialog window.


Preview Files which we are going to publish using visual studio


After previewing all the files finally click on Publish button once we click on publish button publishing will get start and site will get publish in IIS server inside Default Web Site. Following is the snapshot of site getting publish.


Publishing website using web deploy in visual studio


Now to see where IIS located for people who are new to development or deployment just enter Windows + R from keyboard a new Run window will Pop up inside that type text inetmgr then press enter a new window should pop up of Internet Information Services (IIS) Manager. 


Now we can see the site [OrderApp] is deployed to IIS inside Default Web Site that will be like as shown below.


Publish / Deployed App in IIS using Web Deploy in Visual Studio


If you observe our deployed application already started running so we can access application. Here there is a chance of getting error 503 like as shown below


Service Unavailable HTTP Error 503 After Publishing Website


To solve this Error 503 we need to change app pool of deployed application.

Error 503 Resolving in IIS

To Resolve Error, you need go to IIS Manager à then select your Application à then in right side you will see Actions panel inside that select [Basic setting…] a new dialog will pop up with name Edit application like as shown below


Edit Application Pool in IIS for Web Deploy


After that click on select button a new dialog box will popup to select Application Pool in this select ASP.NET V4.0 or any other Application Pool but .Net Framework Version must 4.0.


Select Application Pool v4.0 in IIS to Solve Error


After setting Application Pool now you can check Site it will be Live.


After Deply and Change Application in IIS Result of Deployed Asp.Net MVC Website


This is how we can Web Deploy method in visual studio to deploy web application in IIS / Server.