{infiniteZest}
// Articles. Tutorials. Utilities.
Home  |   Search  |   Login  
Categories Skip Navigation Links
New / All
AJAX
Apple
ASP.NET
.NET
Git
Google / Android
Python / IronPython
Miscellaneous
SQL Server
Which one to use: Web Project or Web Site?
Summary
Visual Studio 2005 and Visual Studio 2008 offer two options for creating an ASP.NET web program – a Web Project or Web Site. This article discusses the main reasons why you would choose one over the other.
 
Table of Contents

Flexibility vs. Clean Usage

Older Versions

Directory Structure Comparison

Figure 1. Web Project and Web Site Directory Comparison

Other Articles

 
Article Series
Previous Article:
Test Your Knowledge: First Web Program (Web Site) in C# Explained
This article is part of the Series:
Article Series: First Programs in C# Explained
Next Article:
Test Your Knowledge: Which one to use: Web Project or Web Site?

A common question arises: with two options (Project or Site) available for creating an ASP.NET web site, which one would you choose? And, why?

These two options (Web Project or Web Site) are discussed in the following articles:

First Web Program (Web Project) in C# Explained

First Web Program (Web Site) in C# Explained

Flexibility vs. Clean Usage

The biggest reason for choosing one type over the other is to have the control over which files are part of your application compilation.

If you choose the Web Site option all the files in that directory (and subdirectories) automatically become part of the site/application. With this, you can move the entire directory to the production machine, and the site will work fine.

With the Web Project option, only those files that are included in the project gets compiled. You can have a whole bunch of other files (even with .aspx, .aspx.cs, and other compilable extensions) in that directory and Visual Studio will ignore them all.

The Web Project option provides flexibility, but the Web Site option makes it easy to maintain the site. Typically, if you are creating a site today, you would want to use the Web Site option; and design it such a way that the other required functionality is in different directories (not underneath the web site directory).

Older Versions

However, sometimes that type of organization is not possible. If your web application came from the old days (Visual Studio 2003, when the Web Site option was not available), the whole site structure might already be very complex and fixed and rigid and there is no easy way to change it.

In those cases, the Web Project option makes life easy.

Directory Structure Comparison

If you used the Web Site option, the whole point is to be able to simply copy the entire directory of that web site root to the production machine and it would work fine and will not contain any extra files.

Figure 1. Web Project and Web Site Directory Comparison

Figure 1. Web Project and Web Site Directory Comparison

As you can see in Figure 1, if you create a web site, there will be fewer directories – you will not see the bin and obj directories. In case of Web Project (in this case the FirstWeb solution), you will actually find a Firstweb.dll in the bin directory.

In case of the Web Site, the solution file (here FirstWebSite.sln) will not be in the root directory of the site (i.e. …\FirstWebSite). It will be in the Users directory like C:\Users\Administrator\Documents\Visual Studio 2008\Projects\FirstWebSite. This makes sense, because, you don’t need or want to copy the solution file to the production server. If it were included with the .aspx files, then you would have to consciously exclude that file when copying the entire directory to the server.

Other Articles

The two options (Web Project or Web Site) for creating a web program with ASP.NET are discussed in the following articles:

First Web Program (Web Project) in C# Explained

First Web Program (Web Site) in C# Explained

Take a Quick Quiz on this Article

1. You want to include some .aspx and aspx.cs files in the ASP.NET solution directory. And, you don’t want them compiled. Which of the following is the best option for creating this web solution?



: You can selectively add files to a project
Question 1 of 5
Article Series
Previous Article:
Test Your Knowledge: First Web Program (Web Site) in C# Explained
This article is part of the Series:
Article Series: First Programs in C# Explained
Next Article:
Test Your Knowledge: Which one to use: Web Project or Web Site?
Bookmark and Share This

More Articles With Similar Tags
icon-first-web-new-project.jpg
This article explains and dissects the pieces involved in creating the first web program in C# using the Web Project method (as opposed to the Web Site method).
How do you develop an ASP.NET program using the Web Project model?
icon-first-web-site-solution-explorer.jpg
This article explains and dissects the pieces involved in creating the first web program in C# using the Web Site method (as opposed to the Web Program method).
What is involved in developing a web-based program using the C# programming language with Web Site - Solution as the model.
This test has questions on developing first console (shell) based programs using the C# programming language.
About  Contact  Privacy Policy  Site Map