Here we will learn how to publish / deploy asp.net mvc web application to iis server using web deploy package in visual studio or use web deploy package option in visual studio to deploy / publish asp.net mvc web application in server with example.
Visual studio 2010 and more versions is having One-Click publish options by using those options we can deploy / publish asp.net 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 Package.
If we select web deploy package method then a .zip package will create in our local disk folder. We need to use use this package to deploy using CMD command prompt or we can mail this package to admin team to deploy this .zip package.
Here we will learn step by step process to deploy or publish asp.net mvc web application using Web Deploy Package 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.
Now let’s build this application and run. Following is the snapshot after running application.
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.
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
After selecting Publish option a new dialog will pop up with name Publish Web like as shown below.
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.
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.
We are new to publish this application hence we are going to create a New Profile.
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.
After selecting a New Profile, a new dialog box will appear with name [New Profile] asking to enter Profile name.
Here we entered profile name as [OrderAppDeploy_WebDeploy_Package] you can enter profile name of your choice.
After entering profile name just click on OK button then this process will move forward to next stage Connection setting.
Now we are going to select a way to publish our application for that we need to move to second step connection and in Publish method we need to select "Web Deploy Package".
To use "Web Deploy Package" for publishing website we need to enter or select Package location and in Site name we need to enter name of site.i.e. like
While choosing Package location select folder location where we want this output to get publish in a folder.
E.g. Here we selected Package location as [C:\Users\sai\Desktop\publish\OrderApp.zip] it’s a publish name folder on desktop.
After entering package location then enter site name as [Default Web Site/OrderApp]
E.g. First enter default website which is in IIS [Default Web Site] then [/] your Application name.
After entering all the details click on Next button to Move Forward to next stage of deployment process.
In this Process it will ask for selecting Configuration we have 2 options for this
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.
Here we selected 2 options of [File Publish options] that will be like as shown below
In case 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.
After completion of adding all database setting now click on OK button. Following is the snapshot after configuring database connection.
After entering all details related to destination Connection String Click on Next button to Move Forward to next stage of deployment process.
In this preview we will not get a chance to view files which we are going to publish in folder because it will warp all files in .zip format. Following is the snapshot of Preview dialog window.
After we saw preview finally click on Publish button to start publishing process.
After publishing process is completed just check folder which we selected for publish these files that will be like as shown below.
We should able to see these kind of files generated. Now we will deploy these files using command prompt.
In publish folder there is a file with name [OrderApp.deploy-readme] just open that file to read how to deploy this package.
Now open command prompt as administrator and access directory where our publish folder .zip file is stored like as shown below
Now enter command OrderApp.deploy.cmd /T and click enter it will create a report of what will happen when we actually deploy the package
After entering command and press enter button it will execute and show the report like as shown below
After checking report now we will deploy package by entering command [OrderApp.deploy.cmd /Y]. Now enter command OrderApp.deploy.cmd /Y and click enter button to publish application.
After executing command OrderApp.deploy.cmd /Y it will publish all the files and the execution process will be like as shown below
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_Deply] is deployed to IIS inside Default Web Site that will be like as shown below.
This is how we can Web Deploy Package method in visual studio to deploy web application in IIS / Server.