When I start a new ASP.NET project in Visual Studio, I can create an ASP.NET Web Application or I can create an ASP.NET Web Site.
What is the difference between ASP.NET Web Application and ASP.NET Web Site? Why would I choose one over other?
Is the answer different based on which version of Visual Studio I am using?
Web Application project model
Web Site project model
This may sound a bit obvious, but I think it's something that is misunderstood because Visual Studio 2005 only shipped with the web site originally. If your project deals with a website that is fairly limited and doesn't have a lot of logical or physical separation, the website is fine. However if it is truly a web application with different modules where many users add and update data, you are better off with the web application.
The biggest pro of the website model is that anything in the
app_code
section is dynamically compiled. You can make C# file updates without a full redeploy. However this comes at a great sacrifice. A lot of things happen under the covers that are difficult to control. Namespaces are difficult to control and specific DLL usage goes out the window by default for anything underapp_code
since everything is dynamically compiled.The web application model does not have dynamic compilation, but you gain control over the things that I have mentioned.
If you are doing n-tier development, I highly recommend the web application model. If you are doing a limited web site or a quick and dirty implementation, the web site model may have advantages.
More detailed analysis can be found in:
Applications are usually compiled before deployment where as the website makes use of the app_code directory. When anything changes in the app code folder the server will re-compile the code. This means that you can add/ change code with a website on the fly.
The advantage of an app is that there is no re-compiling and so initial start up times will be faster.
Here Web Supportive Application is an example of website. Website and Web Application both can be dynamic/static its depends upon requirements, here is an example to understand working of website's and web application.
Definitely web application, single DLL file and easy to maintain. But a website is more flexible; you can edit the aspx file on the go.
Web Site = use when the website is created by graphic designers and the programmers only edit one or two pages
Web Application = use when the application is created by programmers and the graphic designers only edit one or two paged/images.
Web Sites can be worked on using any HTML tools without having to have developer studio, as project files don’t need to be updated, etc. Web applications are best when the team is mostly using developer studio and there is a high code content.
(Some coding errors are found in Web Applications at compile time that are not found in Web Sites until run time.)
Warning: I wrote this answer many years ago and have not used Asp.net since. I expect things have now moved on.