Websites and Web Projects
Somewhat confusingly, Visual Studio offers two ways to create an ASP.NET-powered web
• Project-based development: When you create a web project, Visual Studio generates a .csproj
project file (assuming you’re coding in C#) that records the files in your project and stores a
few debugging settings. When you run a web project, Visual Studio compiles all your code
into a single assembly before launching your web browser.
• Projectless development: An alternate approach is to create a simple website without any
project file. In this case, Visual Studio assumes that every file in the website directory (and its
subdirectories) is part of your web application. In this scenario, Visual Studio doesn’t need to
precompile your code. Instead, ASP.NET compiles your website the first time you request a
page. (Of course, you can use precompilation to remove the first-request overhead for a
deployed web application.)
The first .NET version of Visual Studio used the project model. Visual Studio 2005 removed the
project model in favor of projectless development. However, a small but significant group of developers
revolted. Realizing that there were specific scenarios that worked better with project-based
development, Microsoft released a download that added the project feature back to Visual Studio
2005. Now, both options are supported in Visual Studio 2008.
Projectless development remains popular for the following reasons:
- Projectless development simplifies deployment: You simply need to copy all the files in the
website directory to the web server—there aren’t any project or debugging files to avoid.
- Projectless development simplifies file management: If you want to remove a web page, you
can simply delete the associated files using the file management tool of your choice. If you want
to add a new page or move a page from one website to another, you simply need to copy the
files—there’s no need to go through Visual Studio or edit the project file. You can even author
web pages with other tools, because there’s no project file to maintain.
- Projectless development simplifies team collaboration: Different people can work independently
on different web pages, without needing to lock the project files.
- Projectless development simplifies debugging: When creating a web project, you must recompile
the entire application when you change a single page. With projectless development, each
page is compiled separately, and the page is only compiled when you request it for the first time.
- Projectless development allows you to mix languages: Because each web page is compiled
separately, you’re free to code your pages in different languages. In a web project, you’d be
forced to create separate web projects (which is trickier to manage) or separate class library
The most significant advantages to web projects are the following:
- The project development system is stricter than projectless development: This is because
the project file explicitly lists what files should be part of the project. This allows you to catch
potential errors (such as missing files) and even deliberate acts of sabotage (such as
unwanted files added by a malicious user).
- Web projects allow for more flexible file management: One example is if you’ve created several
separate projects and placed them in subdirectories of the same virtual directory. In this case,
the projects are kept separate for development purposes but are in essence the same application
for deployment. With projectless development, there’s no way to keep the files in these
- Web projects allow for a customizable deployment process: Visual Studio project files work
with the MSBuild utility, which allows project compilation to be automated and customized.
Also, you get more control over the generated assembly for your web application, which you
can name appropriately, sign, and so on.
- Web projects work better in some migration scenarios: For this reason, ASP.NET automatically
converts Visual Studio .NET 2003 web projects to Visual Studio 2008 web projects. This conversion
requires fewer changes to your pages.