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