tags:

views:

763

answers:

11

In VS2008 what is the difference between Web Site and Web Application? And are there advantages to using either one?

+1  A: 

If you're using Visual Studio 2005, Web Application projects compile faster according to this site

for a list of one persons opinions of pros and cons you can check this article.

My personal preference is to just create a website project. I don't really have a reason for doing this, but since it has always worked will for me (I can just drag and drop a directory to deploy) I continue to use it.

ZCHudson
+14  A: 

Before you talk about the pros and cons, you would have to know the fundamental difference on how it works.

Web Site Projects use a just in time compilation approach which would dynamically compiles your aspx and related file when your page is actually visited. The compiled assembly is then being placed inside the bin folder with a random generated dll name.

Web Application, on the other hand, compiles the page into a named dll at the time you develop the project. Without this compilation the website won't even deploy into your server (as there is no auto compile mechanism)

So the pros and cons:

  1. Web Site project's source are dynamic, you don't necessary need to go thru your development machine to modify something (risky approach though), everything are compiled just in time
  2. Having said this is convenient, it also has a slight performance penalty due to the JIT compilation involved.
  3. There are some projects just WONT run on Web Site project due to the design of the dispatching request, like ASP.NET MVC and MonoRail based projects.
  4. You have little or no possibility to TDD your Web Site project in library level because its not compiled. You can however TDD your single DLL compiled with Web Application.
  5. I forgot how that is being triggered but VS2005 can take forever long to compile a bigger Web Site project due to the dynamic nature involves additional syntax checking for the aspx files. Web Application does not suffer from this issue.

I am sure there are a lot more stuffs involved, but I think these are some of the bigger ones.

goodwill
A: 

I would only use the website project for the most trivial app. Anything else that involves multiple developers needs an msbuild script. msbuild likes web application projects and really hates website projects. Besides that, I never felt comfortable with the order that website projects impose. I like to write code, compile, test, deploy. With a website project you get write code, deploy, compile, test. Just rubs me the wrong way.

DancesWithBamboo
A: 

This MSDN article describes in great details the differences between the Web Site and Web Application project.

korchev
A: 

Stephen M. Redd helped me to get started on this one. He prefers the web application project approach.

My task today was to upgrade a .Net 1.1 app to 3.5, it was far easier in my case to take the web application project route as this is much closer to how 1.1 works.

Although I decided against it, the web site approach held the following attractions:

  • no code at all needed to declare page controls (web application project on the other hand auto-generates these into a designer file which I didn't like the look of)
  • dynamic compilation, faster development
  • no need for a project file

Ultimately I'll need to make fewer changes to the code if I go for the web application project route. Unfortunately our app has pages referencing each other through static methods and other such bad practices. The web site approaches compilation method means pages cannot work together regardless of how your namespaces are configured. I guess I'll have to learn to live with the designer files.

Dan Powley
A: 

When developing in a team you always have to choose web application. Because the Bin directory holds all referenced assemblies and you have to check in the Bin directory into source control (very evil). That means you always get conflicts after a compile of your web site and an update from source control (with modifications from another developer).

can you elaborate on that?
djangofan
A: 

hi the link is for vs2005 but i dont think that so much has changed http://www.dotnetspider.com/resources/1520-Difference-between-web-site-web-application.aspx

nWorx
+7  A: 

Web site Primarily for working with ad-hoc web sites that have programmed elements. Easily identified by customer-specific content present in aspx files.

No solution or project files are required and the pages and source can reside locally (file system, IIS) or remotely (FTP, WebDev/FrontPage extensions) via the File > Open > Web Site... menu option.

Code-behind and classes are typically stored on the web server which compiles them in-memory on demand. Changes can be made to the files without restarting the application and losing sessions.

For/Against

  • Quick edit, test, deploy cycle Syntax errors at runtime
  • No need to compile or restart app Can't create an installer
  • Source always available Source on server useful to hackers

Web application Web application projects were introduced as an add-on for Visual Studio 2005, later rolled in to VS 2005 SP1 and made a full first-class citizen with Visual Studio 2008.

Like the name implies these are primarily for web applications, those times when you have written a product or solution that happens to have a web interface.

Web application projects exist on your local drive and are treated like any other VS project type and can be added to existing solutions are subject to full compilation, validation and build steps.

Deployment is typically via MSI installers however you can also utilise the addition Web Deployment Projects add-in which allows you to deployment directly to servers which is useful for deploying to test environments.

For/Against

  • Controlled build & deploy process Deployment causes application restart
  • No class files on web server, dll only Can't deploy individual classes
  • Syntax errors at compile time

http://damieng.com/blog/2008/02/07/web-site-vs-web-application

madcolor
A: 

Web site : its dynamic compilation Web application :its static compilation

visual studio 2005 sp1 provides web Application and in visual studio 2008 : it supports both this concepts .

read myblog

anishmarokey
A: 

There are many articles on this- here, and here, and even here. The main distinction is that a Website Project comprises a folder of related assets that make up the website and anything in that folder is part of the website, while a Website Application is treated more like a desktop app and has a .csproj/vbproj file that lists all of the application content. Also, pages have designer files in a website application.

Nathan Taylor
A: 

Here is Scott Gu's article that sights the differences while he explains about which one to choose between WebSite and Web Application Projects.