Thursday, October 9, 2008

Web Application vs Web Site project model (ASP.NET 2.0)

This is a very common question asked by ASP.NET developers: what project model should be used for ASP.NET applications? Web Site project (which was introduced with VS 2005) or Web Application project (which is delivered as add-in for VS 2005 and built-in with VS 2005 SP1)?

Every project model has it's own advantages and disadvantages. To understand more, lets have a look at the features of these two project models.

Web Application project model

  1. Provides the same Web project semantics as Visual Studio .NET 2003 Web projects
  2. It has a project file (structure based on project files)
  3. All code in the project is compiled into a single assembly (the build model)
  4. It supports both IIS and the built-in ASP.NET Development Server
  5. It 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. Use of FrontPage Server Extensions (FPSE) is no longer a requirement

Web Site project model

  1. No project file (it is based on file system)
  2. It uses a new compilation model. Details can be found from this link.
  3. Uses dynamic compilation. Allows working on pages without building entire site on each page view
  4. It supports both IIS and the built-in ASP.NET Development Server
  5. Each page has its own assembly
  6. It follows a different code model (single page).

Check the below links for more information about the single-page code model and code-behind model:

http://www.odetocode.com/Articles/406.aspx
http://msdn.microsoft.com/hi-in/magazine/cc163675(en-us).aspx

Some other useful articles on the Web Site vs Web Application topic...

http://reddnet.net/code/aspnet-web-site-vs-web-application/
http://reddnet.net/code/asp-net-web-site-vs-web-application-project-part-2/
http://www.codersbarn.com/post/2008/06/ASPNET-Web-Site-versus-Web-Application-Project.aspx

Follow the below link, for installing support for Visual Studio 2005 Web Application projects.

http://msdn.microsoft.com/en-us/asp.net/aa336618.aspx

To summarize; both models have pros and cons. For smaller projects (example; demo purpose) the Web Site model is good, because of the simplicity. If the site that is to be developed is a big one which requires pre-build & post-build steps, has multiple project etc. the Web Application project model should be used. Also, Web Application model is the right choice for converting web sites developed using VS 2003 to VS 2005.

No comments: