Thursday, March 24, 2011

Web Site vs Web Application project in .Net

Website project type was introduced in the VS 2005 and Web Application model introduced in VS 2003. Website project type is based on folder structure and does not require a project file. Later in VS 2005 sp1 project file was introduced for the VS 2005 website project type. Now in VS 2008 we can create both project types.A common question by asp.net developers is what project model should I use for asp.net application?Every project model has it's own advantages and disadvantages.

Major difference between Web Application and Website is when you deploy the WebApps, you can just copy the Compiled Assembly and Visual elements to the IIS folder where as in Website you need to copy everything to the IIS to work.

Website:
It is a collection of web pages and other information such as images, sound, and video files, etc. that are made available to end users using different browsers like IE, FireFox, Chrome etc. through a single web server.


Web Application:
A web application serves a specific function such a shopping cart or a blogging application.

A web site can be a collection of several web applications. 

Web Application project model
  1. Provides the same Web project semantics as Visual Studio .NET 2003 Web projects.
  2. Has a project file (structure based on project files).
  3. Build model - all code in the project is compiled into a single assembly.
  4. Supports both IIS and the built-in ASP.NET Development Server.
  5. 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).
  6. Using FrontPage Server Extensions (FPSE) are no longer a requirement.
Web Site project model
  1. No project file (Based on file system).
  2. New compilation model.  (Read here or here for more details) and ...
  3. Dynamic compilation and working on pages without building entire site on each page view.
  4. Supports both IIS and the built-in ASP.NET Development Server.
  5. Each page has it's own assembly.
  6. Different code model.  (Read here for more details)
Which model should I use?
  1. You need to migrate large Visual Studio .NET 2003 applications to VS 2005? use the Web Application project.
  2. You want to open and edit any directory as a Web project without creating a project file? use Web Site project.
  3. You need to add pre-build and post-build steps during compilation? use Web Application project.
  4. You need to build a Web application using multiple Web projects? use Web Application project.
  5. You want to generate one assembly for each page? use Web Site project
  6. You prefer dynamic compilation and working on pages without building entire site on each page view? use Web Site project
  7. You prefer single-page code model to code-behind model? use Web Site project.