Site icon Ryadel

Visual Studio - ASP.NET Web Site Project vs Web Application Project

Visual Studio 2017 - Lost Razor Intellisense and Syntax Highlight - How to Fix it

When you start a new ASP.NET project in Visual Studio, you have the chance to create a new ASP.NET Web Site project or a ASP.NET Web Application project. This is true since Visual Studio 2008, being it the first VS installment where the ASP.NET Web Application Project template was introduced.

What are the differences between these two project templates? Should you choose the ASP.NET Web Site or should you go with the ASP.NET Web Application instead?

The answer can be easily inferred from the following article from the official MS knowledge base, which clearly explains the differences between these two project templates and emphasize the pros and cons of each choice:

However, for the sake of convenience, we'll briefly summarize the gist in this post.

ASP.NET Web Site

The Web Site project is compiled on the fly. You end up with a lot more DLL files, which can be a pain. It also gives problems when you have pages or controls in one directory that need to reference pages and controls in another directory since the other directory may not be compiled into the code yet. Another problem can be in publishing.

If Visual Studio isn't told to re-use the same names constantly, it will come up with new names for the DLL files generated by pages all the time. That can lead to having several close copies of DLL files containing the same class name, which will generate plenty of errors. The Web Site project was introduced with Visual Studio 2005, but it has turned out not to be extremely popular.

Key factors

  • No project file (based on file system).
  • Non-standard compilation model (read here for more details)
  • Dynamic compilation and working on pages without building entire site on each page view.
  • Supports both IIS and the built-in ASP.NET Development Server.
  • Each page has it's own assembly.
  • Different code model (read here for more details).

ASP.NET Web Application

The Web Application Project was created as an add-in and now exists as part of SP 1 for Visual Studio 2005. The main differences are the Web Application Project was designed to work similar to the Web projects that shipped with Visual Studio 2003. It will compile the application into a single DLL file at build time. In order to update the project, it must be recompiled and the DLL file published for changes to occur.

Another nice feature of the Web Application project is it's much easier to exclude files from the project view. In the Web Site project, each file that you exclude is renamed with an excluded keyword in the filename. In the Web Application Project, the project just keeps track of which files to include/exclude from the project view without renaming them, making things much tidier.

Key factors

  • Provides the same Web project semantics as Visual Studio .NET 2003 Web projects.
  • Has a project file (structure based on project files).
  • Build model - all code in the project is compiled into a single assembly.
  • Supports both IIS and the built-in ASP.NET Development Server.
  • Supports all the features of Visual Studio 2005 (refactoring, generics, etc.) and of ASP.NET 2.0 (master pages, membership and login, site navigation, themes, etc).
  • Using FrontPage Server Extensions (FPSE) are no longer a requirement.

What should you choose?

If you still got doubts, we strongly suggest to take a look at this excellent post which gives reasons on why to use one and not the other. Here's an excerpt of it:

  • You need to migrate large Visual Studio .NET 2003 applications to VS 2005? Use the Web Application project.
  • You want to open and edit any directory as a Web project without creating a project file? Use Web Site project.
  • You need to add pre-build and post-build steps during compilation? Use Web Application project.
  • You need to build a Web application using multiple Web projects? Use Web Application project.
  • You want to generate one assembly for each page? Use Web Site project.
  • You prefer dynamic compilation and working on pages without building entire site on each page view? Use Web Site project.
  • You prefer single-page code model to code-behind model? Use Web Site project.

Conclusions

That's about it: I hope this post will allow you to have clearer ideas on these two project templates, allowing you to make the choice that best suits your needs.

 

Exit mobile version