Click here to Skip to main content
16,021,621 members
Articles / Web Development / ASP.NET

How to deploy ASP.NET Web Application on server

Rate me:
Please Sign up or sign in to vote.
4.43/5 (31 votes)
19 Jan 2010CPOL5 min read 406.5K   12.9K   51   20
Article explaining about diferent ways to deploy ASP.NET web application on server


Introduction

Hello, in this article i have tried to explain, how a web application is deployed on to web server.

Deployment refers to the process of copying an asp.net web application from the development system to the server on which the application will be run. There are several way we can deploy our web application

We can deploy ASP.NET Application in  3 different ways

  • xCopy Deployment
  • Precompiled Deployment 
  • Web Setup Project   
The choice of best deployment alternative depends upon particular need of each application. Xcopy deployment is the most easiest, and it is often used during development to create copies of an application n different servers for testing purpose. For small application xcopy deployment may be the best choice.

Precompiled deployment has several advantages over XCopy deployment. Eg. Precompiled deployment is always gives better performance for the first users of the site at the same time it is more secure as we don’t need to copy our source code files on to server. If our application deployed on one or few servers then precompiled deployment is usually best choice.

When we are going to deploy our application on number of servers then creating a setup program is a very handy tool. Although creating this setup program is much tedious and involves considerable working, the deployment from this setup program becomes very easier.

xCopy Deployment   

To manually copy the files of an asp.net web site to a server. We can use the xcopy command from a command prompt. Then we can use IIS’s (Internet Information Serve management console t o create a virtual directory that’s mapped to the directory that you copied the web site to.

It is easier to create a batch file for the xcopy command. Then after we can run that batch file at given time we make changes to the application and want to deploy the updated code.

We can also perform xcopy deployment from visual studio by using copy website command. 

To perform xcopy we use copy web site command. This command lets us to copy website to file system, local IIS, FTP or remote IIS website. At the same time we can copy all or selected files.

How to use this command 

  1. In visual studio open the website to be deployed and choose the website copy web site command.
  2. Then click the connect button to display an open website dialog box that lets to choose the destination to copy the web site to.
  3. Click the arrow buttons to copy the files from the source web site to remote web site.

Publish Web Site 

The publish web site command lets us to precompile an asp.net application and copy the precompiled assemblies to a target server. This is the easiest way to use the precompiled deployment feature.

  • Deploys precompiled assemblies to the specific server
  • Lets us to deploy the web site without source code files
  • It is done either from publish web site command or from command prompt using the aspnet_compiler command 
 
Advantages
  • Avoids delays caused by compiling web pages when they are first accessed by a user.
  • Finds compile errors before the site is deployed.
  • Can copy just executable files and not the source files to the server.

The build -> publish web site command compiles all of the files makes up an asp.net application, and then deploys the compiled assemblies to the location we specify.

Publish Web Site

If we check allow precompiled site to be updatable box, the source files are deployed along with the executable files. If we uncheck then source code files aren’t deployed.

The syntax of aspnet_compiler command
The aspnet_compiler command is located in the asp.net framework directory,
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

aspnet_compiler –v virtual-directory [-u] [-d] [-f] [target-directory]

where

  • -v name of virtual directory of existing web site
  • -u precompiled website will be updated
  • -d debug information is included in compiled assemblies
  • -f overwrite target directory if exist


Eg.
Precomplies existing website
Aspnet_compiler –v test d:\test

In same place
Aspnet_complier –v test

With debugging information
Aspnet_compiler –v test –u –d d:\test

If we specify target directory the precompiled web site is stored in the specified directory else the website is precompiled in place

Setup Deployment

  • It uses a web setup project to build a windows setup program used to deploy website onto server.
  • Useful for deployment on multiple servers.
  • Can be used to deploy precompiled assemblies and can be configured to include or omit the source code.
  • The installed application can be removed by using add or remove programs dialog box from control panel

How to create a setup
Choose the file -> add -> new project command to display the add new project dialog box. Then, choose setup and deployment. Select web setup project as template, enter a name for websetup project click ok.

Add project to Out put Group  

In the solution explorer right click the web setup project and choose the add-> project output command to display the add project output group dialog box, then click ok to add the content files from you website to the web setup project

Use the buttons that are displayed at the top of the solution explorer when web setup project is selected to access setup editors that lets us to customize various aspects of the web setup project.

Add setup prerequisites 

 

Visual studio creates files named setup.exe and setup.msi. setup.exe is the file we will run to install the application and setup.msi contains all of the files to be installed.

The setup.exe and setup.msi files are stored in the web setup project’s debug or release folder.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior) Excel Informatics, Pune
India India
Am Indrajeet T. Sutar. I am a web developer. I am working on .net technology. I have completed my Masters in Computers and Management (people call it as MCA, MBA etc.) Apart from programming i do photography (not regularly though), traveling and reading books.

Comments and Discussions

 
Questiondeploy and install c# project in web server Pin
Member 1075135724-Dec-14 6:27
Member 1075135724-Dec-14 6:27 
Question[My vote of 1] meh Pin
jamagboo14-Apr-14 23:16
jamagboo14-Apr-14 23:16 
GeneralThis is exactly what I needed Pin
Member 985690918-Feb-14 8:57
Member 985690918-Feb-14 8:57 
QuestionThe setup.exe and setup.msi files are stored in the web setup project’s debug or release folder. Pin
Harisul Islam23-Nov-13 16:08
Harisul Islam23-Nov-13 16:08 
GeneralMy vote of 1 Pin
Reza Oruji21-Aug-13 0:03
Reza Oruji21-Aug-13 0:03 
GeneralMy vote of 1 Pin
umamahesh20207-Aug-13 19:40
umamahesh20207-Aug-13 19:40 
QuestionASP. Net Hosting Problem Pin
The Kaushik Basu25-Feb-13 15:27
The Kaushik Basu25-Feb-13 15:27 
GeneralMy vote of 1 Pin
GoutamK3-Jan-13 23:35
professionalGoutamK3-Jan-13 23:35 
Questionasp.net sit deployment with sql server database Pin
joinsst29-Nov-12 1:37
joinsst29-Nov-12 1:37 
GeneralMy vote of 5 Pin
joinsst29-Nov-12 1:35
joinsst29-Nov-12 1:35 
QuestionWeb setup projects are not supported in VS 2012. Pin
Michael Freidgeim20-Sep-12 2:11
Michael Freidgeim20-Sep-12 2:11 
QuestionProblem in installing the web set up Pin
su_ma201026-Jan-12 19:10
su_ma201026-Jan-12 19:10 
GeneralMy vote of 3 Pin
chirag.khatsuriya2-Dec-11 21:40
chirag.khatsuriya2-Dec-11 21:40 
GeneralMy vote of 4 Pin
Narendra G. mane.28-Oct-11 21:11
Narendra G. mane.28-Oct-11 21:11 
GeneralMy vote of 4 Pin
jitendra prajapat4-Oct-11 2:40
jitendra prajapat4-Oct-11 2:40 
Generalthanks Pin
BSRK24-Mar-11 20:14
BSRK24-Mar-11 20:14 
GeneralMy vote of 1 Pin
chenameni27-Sep-10 22:59
chenameni27-Sep-10 22:59 
QuestionWhy not use a deployment tool to help manage the application maintenance? Pin
Daniel Kushner20-Jan-10 17:56
Daniel Kushner20-Jan-10 17:56 
GeneralMy vote of 1 Pin
g0got219-Jan-10 20:01
g0got219-Jan-10 20:01 
GeneralRe: My vote of 1 Pin
sachinthamke31-Jan-11 2:11
sachinthamke31-Jan-11 2:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.