Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to deploy ASP.NET Web Application on server

, 19 Jan 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Indrajeet Sutar
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

 
Question[My vote of 1] meh Pinmemberjamagboo14-Apr-14 23:16 
GeneralThis is exactly what I needed PinmemberMember 985690918-Feb-14 8:57 
QuestionThe setup.exe and setup.msi files are stored in the web setup project’s debug or release folder. PinmemberHarisul Islam23-Nov-13 16:08 
GeneralMy vote of 1 PinmemberReza Oruji21-Aug-13 0:03 
GeneralMy vote of 1 Pinmemberumamahesh20207-Aug-13 19:40 
QuestionASP. Net Hosting Problem PinmemberThe Kaushik Basu25-Feb-13 15:27 
GeneralMy vote of 1 PinmemberGoutamkumar73-Jan-13 23:35 
Questionasp.net sit deployment with sql server database Pinmemberjoinsst29-Nov-12 1:37 
GeneralMy vote of 5 Pinmemberjoinsst29-Nov-12 1:35 
QuestionWeb setup projects are not supported in VS 2012. PinmemberMichael Freidgeim20-Sep-12 2:11 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 19 Jan 2010
Article Copyright 2010 by Indrajeet Sutar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid