Click here to Skip to main content
15,868,016 members
Articles / Web Development / ASP.NET
Article

Deploying Web Applications using Visual Studio .NET

Rate me:
Please Sign up or sign in to vote.
3.23/5 (52 votes)
31 Aug 20023 min read 407.3K   100   76
Deploying an ASP.NET project using the Visual Studio .NET Windows Installer

Introduction

Deployment is a great feature in Visual Studio .NET which allows you to deploy your applications by creating a Setup Program. You can make a setup project for both your Windows and Web applications.

Using this feature for deploying has many advantages for example:

  • Installed applications can be uninstalled completely.
  • If an error occurred through installation process, the system goes back to the state of before the installation.
  • Adding user interface to setup project easily.
  • Making setup project on different kinds of distribution media such as CD or floppy disks.
  • Easy reinstallation when installed files get corrupted.

In this article, I will create a simple ASP.NET Web project and then create a setup project for deploying that.

First of all create an ASP.NET Web project using Visual Studio .NET and name it for example "TestWeb". In the WebForm designer (WebForm1.aspx). Drag and drop a Label and a button server control. Double click on button and then add the following code and compile the project.

private void Button1_Click(object sender, System.EventArgs e)
{
    Label1.Text = "My first deployment web project";
}  

Creating the Web Setup project

After creating the web project or opening an existing web project, You can use VS.NET installer to create a Web Setup project. So do the following steps.

Add a Web Setup project to the solution through File/New/Project menu. Choose the Setup and Deployment Projects in Project Types tree control and after that select the Web Setup Project from Templates list box and name it WebSetup. Be aware of select the Add to Solution radio button.

Image 1

Now the project is added to the Solution Explorer, and you can see the File System Editor. With File System Editor, you can add files and dependencies to the setup project and configure the location of installation.

Image 2

Now you must add project files and dependencies to the setup project. For this reason right click on the Web Application Folder in File System Editor and choose Add/Project Output from the menu (You can do this through Action menu as well). Then select the Primary Output and Content Files from the Add Project Output Group dialog.

Image 3

By pressing the OK button the primary output and content files of the TestWeb project will be added to the Application Folder automatically. Also the dependencies are automatically detected in the Solution Explorer. As you can see the dotnetfxredist_x86_enu.msm merge module is added to the WebSetup project. This merge module includes all assemblies of .NET framework. The exclude property of dotnetfxredist_x86_enu.msm is TRUE by default. In our case we suppose that .NET runtime is already installed on the target machine, otherwise you can define .NET Framework Lauch Condition in your setup project.

In the properties window, set the DefaultDocument property to "Webform1.aspx" page.

It's now time to build your web setup. So right click on WebSetup on Solution Explorer and choose Build. With a successful build, you can find the following files in the Debug or Release directory (depending on your build settings).

Image 4

By executing Setup.exe the TestWeb project will be installed on the target system. Since we excluded .NET framework from our setup project, we must install the TestWeb application on the system with .NET framework installed. After installation process you can see TestWeb in IIS directory.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
Iran (Islamic Republic of) Iran (Islamic Republic of)
I am an independent principal software
developer and architect with nearly 20 years of
hands-on experience in the Microsoft
technology stack with a special focus on .NET
Framework (.NET Core). While working primarily
in the industrial area, I learned how to deliver
critical software systems that are highly
available, secure, and fast.
I am now a senior backend developer delivering
SaaS applications running on cloud and
on-premises. I am generally interested in Clean
Architecture, DDD, Microservices, Azure and AWS

Comments and Discussions

 
QuestionAccessing The Deployed Project Pin
Andile Mkhumane10-Apr-12 3:29
Andile Mkhumane10-Apr-12 3:29 
QuestionHow to Generate the URl. Pin
AustinRocks201010-Mar-10 17:55
AustinRocks201010-Mar-10 17:55 
GeneralNot Bad , i could Follow Pin
Vimalsoft(Pty) Ltd22-Jan-09 2:31
professionalVimalsoft(Pty) Ltd22-Jan-09 2:31 
GeneralThanks! Pin
Tony Rabun30-Jul-08 8:32
Tony Rabun30-Jul-08 8:32 
QuestionInclude new Folder Pin
aigama27-Nov-07 21:51
aigama27-Nov-07 21:51 
AnswerRe: Include new Folder Pin
Majid Shahabfar27-Nov-07 22:21
Majid Shahabfar27-Nov-07 22:21 
GeneralRe: Include new Folder Pin
aigama27-Nov-07 22:25
aigama27-Nov-07 22:25 
GeneralRe: Include new Folder Pin
aigama28-Nov-07 2:14
aigama28-Nov-07 2:14 
Questioni need how to deployee Pin
Prabhukarthik18-Apr-07 19:54
Prabhukarthik18-Apr-07 19:54 
Questionplease help Pin
Member 383479813-Mar-07 20:56
Member 383479813-Mar-07 20:56 
Generaladd folder on target machine Pin
puiutzz5-Feb-07 1:53
puiutzz5-Feb-07 1:53 
Generaladd folder on tare Pin
puiutzz5-Feb-07 1:53
puiutzz5-Feb-07 1:53 
GeneralCreate Web setup project Pin
km.Sumit4-Feb-07 23:45
km.Sumit4-Feb-07 23:45 
GeneralCreate Web setup project Pin
dtchinh6-Nov-07 22:53
dtchinh6-Nov-07 22:53 
GeneralDotNetFrameWork in Web Setup Project Pin
narcis050526-Sep-06 19:09
narcis050526-Sep-06 19:09 
QuestionAdd comtent files to set up project Pin
Arch22k30-Aug-06 21:25
Arch22k30-Aug-06 21:25 
QuestionHow to create the asp.net setup Pin
strongmind9-Jul-06 21:07
strongmind9-Jul-06 21:07 
GeneralMost helpful Pin
Iyad Abu Abdu30-Mar-06 2:48
Iyad Abu Abdu30-Mar-06 2:48 
GeneralAdd/Project Output and Primary Output and Content Files Pin
amalien5-Mar-06 9:32
amalien5-Mar-06 9:32 
Generalhi all Pin
zeny8427-Feb-06 22:16
zeny8427-Feb-06 22:16 
GeneralRe: hi all Pin
DY_public1-Mar-06 6:54
DY_public1-Mar-06 6:54 
GeneralRe: hi all Pin
HimaBindu Vejella2-Apr-06 18:45
HimaBindu Vejella2-Apr-06 18:45 
GeneralDepoly manually at another PC Pin
sugardaddy227-Nov-05 2:34
sugardaddy227-Nov-05 2:34 
GeneralRe: Depoly manually at another PC Pin
Rubysbox26-Mar-07 23:58
professionalRubysbox26-Mar-07 23:58 
GeneralContent Files Pin
Anonymous18-Oct-05 21:21
Anonymous18-Oct-05 21:21 

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.