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

Deploying Web Sites Using Visual Studio 2005

, 19 Oct 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
This article describe various ways to deploy your ASP.NET sites on IIS using the Visual Studio 2005 IDE.

Introduction

The Visual Studio 2005 IDE provides us some useful ways to deploy our web sites on a Web Server (IIS). Most of the time, we are going to deploy our application by creating a Virtual Directory on IIS and this is the best way to deploy it. But sometimes we need to deploy our applications directly from VS. Visual Studio includes features that integrate with IIS and allows us to create Virtual Directories within the Visual Studio IDE.

Visual Studio provides three important features to deploy our websites:

  • Creating a virtual directory at the time of creating a new web project
  • Using the Copy Web tool
  • Publishing a web site

Creating a virtual directory at the time of creating a new web project

From Visual Studio, when we create a web site, simultaneously create a virtual directory for that web site. In the general case, we create a web site in our local system and Visual Studio uses its own built-in web server to run that application. But if we want do so, Visual Studio won't use its built-in web server to deploy the sites, rather a request will be sent to IIS and then IIS will take care of it. Now let us see how to do do this.

Steps:

  1. Visual Studio > File > New Web Site.
  2. VS20054.jpg

    In that screen, select HTTP in the Location field instead of File System (default). Now provide the URL for that application, as given in the picture. Visual Studio will create a Virtual Directory on IIS with the named "mydemosites". If that Virtual Directory already exists, it will not create it, it will just use the existing one.

  3. Click on OK. Check the Solution path. It will be in localhost.
  4. VS20053.jpg

    Visual Studio does has limited functionality of IIS Manager. We can create a Virtual Directory with an existing application.

  5. Click on Browse button of New Window [shown in the first image].
  6. Select Default Web Sites.
  7. VS20055.jpg

  8. Click on Create Virtual Directory, give an alias name and folder path.
  9. VS20056.jpg

This approach has certain limitations:

Limitations

  • If development and production environment are same then all the changes in your application directly affects the live environment, which is not at all preferable.
  • The Virtual Directory will be created at the start of your application. We don't have any option to create a virtual directory that way for an existing application.
  • Application location should be C:/inetpub/wwwroot, which is some times not preferable to manage other resources of your application.
  • We can't configure other settings like Authentication settings, default pages, custom errors, etc.

Using the Copy Web tool

Visual Studio provides a useful tool to transfer our web application files directly from Visual Studio.

Steps

  1. Your Web Site > right click > copy Web Site.
  2. Click on Copy Web Site... The following screen will appear.
  3. VS20059.jpg

    In the Copy Web tool, there are two windows: current location, which is our local solution file, and a remote site that is our target location. First of all, we have to set the target server to enable the area. For that, we need to click on Connect.

    VS200510.jpg

    Now, a new window will appaer, using which we can specify the location for the remote web site.

    • File System: Remote location will be the local system or a network folder, it will just create a new folder to store the application.
    • Local IIS: Create a Virtual Directory on IIS under default web sites. We can also create a new virtual directory as shown earlier.
    • FTP site: It is used for the FTP site, we need to configure FTP for that.
    • Remote Site: We have to specify the remote site URL for copying the files.

    VS200511.jpg

    After we specify the location, we will have the enabled remote server section and enabled button to copy files.

    VS200512.jpg

Publishing a web site

This feature helps us to deploy our application to a production server and keep the source code secure. Visual Studio Publishing Features use the aspnet_complier command line utility to secure our code. It will just publish the site after compiling the code. We just need to deploy it on IIS server. There are only a few steps.

Steps

  1. Right click on Web Site > Publish Web Site.
  2. VS200513.jpg

  3. Set the location for your publishing, you can directly deploy to IIS or set location as already discussed. Check 'Allow this precompiled site to be updateable'. This will help you to change code on your live site without recompiling. E.g., suppose you need to change an alert message, just change the client code and it will be reflected on the live site, and you do not need to recompile.

These are the three approaches provided by VS2005. Hope you enjoyed the article.

References

History

  • Written on Sunday, Octbor 19, 2008.

License

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

Share

About the Author

Abhijit Jana
Technical Lead
India India
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband
 
Blog : http://abhijitjana.net
Web Site : http://dailydotnettips.com
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 PinmemberShanmugam R P27-Oct-11 17:55 

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 | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 19 Oct 2008
Article Copyright 2008 by Abhijit Jana
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid