ASP.NET Web Site or ASP.NET Web Application?
NickName:Robert S. Ask DateTime:2008-12-30T00:24:13

ASP.NET Web Site or ASP.NET Web Application?

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?

Copyright Notice:Content Author:「Robert S.」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/398037/asp-net-web-site-or-asp-net-web-application

Answers
YuMei 2011-07-07T11:56:05

From the MCTS self paced training kit exam 70-515 book:\n\n\n With web application (project),\n \n \n You can create an MVC application.\n Visual Studio stores the list of files in a project file (.csproj or .vbproj), rather than relying on the folder structure.\n You cannot mix Visual Basic and C#.\n You cannot edit code without stopping a debugging session.\n You can establish dependencies between multiple web projects.\n You must compile the application before deployment, which prevents you from testing a page if another page will not compile.\n You do not have to store the source code on the server.\n You can control the assembly name and version.\n You cannot edit individual files after deployment without recompiling.\n \n",


jovenb 2012-07-05T03:26:16

It is always depends on the requirement of your client. ASP.NET just includes flexible features that the user needs for security and easy maintenance of your application.\n\nYou can think of a Web application as a binary file that runs inside the ASP.NET framework. And Web sites as a static webpage that you can review and easily deploy source code to.\n\nBut the advantage and disadvantages of these two ASP.NET technologies come what is good.",


AnthonyWJones 2009-01-24T12:17:22

It depends on what you are developing.\n\nA content-oriented website will have its content changing frequently and a Website is better for that.\n\nAn application tends to have its data stored in a database and its pages and code change rarely. In this case it's better to have a Web application where deployment of assemblies is much more controlled and has better support for unit testing.",


Goodmedalist 2012-07-04T18:46:48

In Web Application Projects, Visual Studio needs additional .designer files for pages and user controls. Web Site Projects do not require this overhead. The markup itself is interpreted as the design.",


Himanshu 2013-01-03T13:52:50

\n Compilation Firstly there is a difference in compilation. Web Site is not pre-compiled on server, it is compiled on file. It may be\n an advantage because when you want to change something in your Web\n Site you can just download a specific file from server, change it and\n upload this file back to server and everything would work fine. In Web\n Application you can't do this because everthing is pre-compiled and\n you end up with only one dll. When you change something in one file of\n your project you have to re-compile everything again. So if you would\n like to have a possibility to change some files on server Web Site is\n better solution for you. It also allows many developers to work on one\n Web Site. On the other side, if you don't want your code to be\n available on server you should rather choose Web Application. This\n option is also better for Unit Testing because of one DLL file being\n created after publishing your website.\n\n\nProject structure\n There is also a difference in the structure of the project. In Web Application you have a project file just like you had it in normal application. In Web Site there is no traditional project file, all you have is solution file. All references and settings are stored in web.config file.\n@Page directive\n There is a different attribute in @Page directive for the file that contains class associated with this page. In Web Application it is standard \"CodeBehind\", in Web Site you use \"CodeFile\". You can see this in the examples below:\n\nWeb Application:\n\n<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"Default.aspx.cs\" \nInherits=\"WebApplication._Default\" %> \n\n\nWeb Site:\n\n<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"Default.aspx.cs\" Inherits=\"_Default\" %> \n\n\n\n Namespaces - In the example above you can see also another difference -\n how namespaces are created. In Web Application namespace is simply a\n name of the project. In Website there is default namespace ASP for\n dynamically compiled pages.\n \n Edit and Continue- In Web Application Edit and Continue option is\n available (to turn it on you have to go to Tools Menu, click Options\n then find Edit and Continue in Debugging). This feature is not working\n in Web Site.ASP.NET MVCIf you want to develop web applications using\n \n ASP.NET MVC (Model View Controller) the best and default option is\n Web Application. Although it's possible to use MVC in Web Site it's\n not recommended.\n \n Summary - The most important difference between ASP.NET Web Application\n and Web Site is compilation. So if you work on a bigger project where\n a few people can modify it it's better to use Web Site. But if you're\n doing a smaller project you can use Web Application as well.\n",


Mukesh Kumar 2014-01-02T05:10:45

WebSite : It generates app_code folder automatically and if you publish it on the server and after that if you do some changes in any particular file or page than you don't have to do compile all files.\n\nWeb Application It generates solutions file automatically which website doesn't generate and if you change in one file than you have to compile full project to reflects its changes.",


Nilesh Rathod 2013-04-04T12:54:24

Yes web application is much better than web sites, because Web applications give us freedom:\n\n\nTo have multiple projects under one umbrella and establish project\ndependencies between. E.g. for PCS we can have following within web\napplication-\n\n\nWeb portals \nNotification Controller (for sending Email) \nBusiness layer \nData Access layer \nException Manager\nServer utility\nWCF Services (Common for all platforms)\nList item\n\nTo run unit tests on code that is in the class files that are\nassociated with ASP.NET pages\nTo refer to the classes those are\nassociated with pages and user controls from standalone classes\nTo create a single assembly for the entire site\nControl over the assembly name and version number that is generated for the site\nTo avoid putting source code on a production server. (You can avoid\ndeploying source code to the IIS server. In some scenarios, such as\nshared hosting environments, you might be concerned about\nunauthorized access to source code on the IIS server. (For a web\nsite project, you can avoid this risk by pre-compiling on a\ndevelopment computer and deploying the generated assemblies instead\nof the source code. However, in that case you lose some of the\nbenefits of easy site updates.)\nPerformance Issue with Website(The\nfirst request to the web site might require the site to be compiled,\nwhich can result in a delay. And if the web site is running on an\nIIS server that is short on memory, including the entire site in a\nsingle assembly might use more memory than would be required for\nmultiple assemblies.)\n",


Nagaraj P 2012-08-28T04:36:07

Websites - No solution file will be created. If we want to create websites no need for visual studio.\n\nWeb Application - A solution file will be created. If we want to create web application should need the visual studio. It will create a single .dll file in bin folder. ",


Sam Cogan 2009-01-24T12:19:07

One of the key differences is that Websites compile dynamically and create on-the-fly assemblies. Web applicaitons compile into one large assembly.\n\nThe distinction between the two has been done away with in Visual Studio 2008.",


Imran Chaudhary 2014-10-28T08:07:01

In a web application you can create the layers of your project's functionality and can create inter-dependencies between them by dividing it into many projects, but you can never do this on a website.",


Max Toro 2009-03-09T19:16:42

Web Site is what you deploy to an ASP.NET web server such as IIS. Just a bunch of files and folders. There’s nothing in a Web Site that ties you to Visual Studio (there’s no project file). Code-generation and compilation of web pages (such as .aspx, .ascx, .master) is done dynamically at runtime, and changes to these files are detected by the framework and automatically re-compiled. You can put code that you want to share between pages in the special App_Code folder, or you can pre-compile it and put the assembly in the Bin folder.\n\nWeb Application is a special Visual Studio project. The main difference with Web Sites is that when you build the project all the code files are compiled into a single assembly, which is placed in the bin directory. You don’t deploy code files to the web server. Instead of having a special folder for shared code files you can put them anywhere, just like you would do in class library. Because Web Applications contains files that are not meant to be deployed, such as project and code files, there’s a Publish command in Visual Studio to output a Web Site to a specified location.\n\nApp_Code vs Bin\n\nDeploying shared code files is generally a bad idea, but that doesn’t mean you have to choose Web Application. You can have a Web Site that references a class library project that holds all the code for the Web Site. Web Applications is just a convenient way to do it.\n\nCodeBehind\n\nThis topic is specific to .aspx and .ascx files. This topic is decreasingly relevant in new application frameworks such as ASP.NET MVC and ASP.NET Web Pages which do not use codebehind files.\n\nBy having all code files compiled into a single assembly, including codebehind files of .aspx pages and .ascx controls, in Web Applications you have to re-build for every little change, and you cannot make live changes. This can be a real pain during development, since you have to keep re-building to see the changes, while with Web Sites changes are detected by the runtime and pages/controls are automatically recompiled.\n\nHaving the runtime manage the codebehind assemblies is less work for you, since you don't need to worry about giving pages/controls unique names, or organizing them into different namespaces.\n\nI’m not saying deploying code files is always a good idea (specially not in the case of shared code files), but codebehind files should only contain code that perform UI specific tasks, wire-up events handlers, etc. Your application should be layered so that important code always end up in the Bin folder. If that is the case then deploying codebehind files shouldn't be considered harmful.\n\nAnother limitation of Web Applications is that you can only use the language of the project. In Web Sites you can have some pages in C#, some in VB, etc. No need for special Visual Studio support. That’s the beauty of the build provider extensibility.\n\nAlso, in Web Applications you don't get error detection in pages/controls as the compiler only compiles your codebehind classes and not the markup code (in MVC you can fix this using the MvcBuildViews option), which is compiled at runtime.\n\nVisual Studio\n\nBecause Web Applications are Visual Studio projects you get some features not available in Web Sites. For instance, you can use build events to perform a variety of tasks, e.g. minify and/or combine Javascript files.\n\nAnother nice feature introduced in Visual Studio 2010 is Web.config transformation. This is also not available in Web Sites. Now works with Web Sites in VS 2013.\n\nBuilding a Web Application is faster than building a Web Site, specially for large sites. This is mainly because Web Applications do not compile the markup code. In MVC if you set MvcBuildViews to true then it compiles the markup code and you get error detection, which is very useful. The down side is that every time you build the solution it builds the complete site, which can be slow and inefficient, specially if you are not editing the site. l find myself turning MvcBuildViews on and off (which requires a project unload). On the other hand, with Web Sites you can choose if you want to build the site as part of the solution or not. If you choose not to, then building the solution is very fast, and you can always click on the Web Site node and select Build, if you’ve made changes.\n\nIn an MVC Web Application project you have extra commands and dialogs for common tasks, like ‘Add View’, ‘Go To View’, ‘Add Controller’, etc. These are not available in an MVC Web Site.\n\nIf you use IIS Express as the development server, in Web Sites you can add virtual directories. This option is not available in Web Applications.\n\nNuGet Package Restore does not work on Web Sites, you have to manually install packages listed on packages.config Package Restore now works with Web Sites starting NuGet 2.7",


Waleed Eissa 2009-09-28T12:21:32

I recommend you watch the video Web Application Projects & Web Deployment Projects on the ASP.NET website which explains the difference in great detail, it was quite helpful to me.\n\nBy the way, don't get confused by the title, a great part of the video explains the difference between website projects and web application projects and why Microsoft re-introduced Web application projects in Visual studio 2005 (as you probably already know, it originally shipped with only website projects then web application projects were added in SP1). A great video I highly recommend for anyone who wants to know the difference.",


gadasadox 2013-01-21T11:04:50

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.",


Ian Ringrose 2009-03-04T14:19:03

Web Site = use when the website is created by graphic designers and the programmers only edit one or two pages\n\nWeb Application = use when the application is created by programmers and the graphic designers only edit one or two paged/images.\n\nWeb 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.\n\n(Some coding errors are found in Web Applications at compile time that are not found in Web Sites until run time.)\n\nWarning: I wrote this answer many years ago and have not used Asp.net since. I expect things have now moved on.",


Daisy Moon 2009-08-15T17:03:07

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.\n\nThe advantage of an app is that there is no re-compiling and so initial start up times will be faster. ",


cdonner 2014-09-23T21:55:24

Web applications require more memory, presumably because you have no choice but to compile into a single assembly. I just converted a large legacy site to a web application and have issues with running out of memory, both at compile time with the error message as below : \n\nUnexpected error writing metadata to file '' -- \nNot enough storage is available to complete this operation. \n\n\nerror, and at runtime with this error message as below :\n\nException information: \n Exception type: HttpException \n Exception message: Exception of type 'System.OutOfMemoryException' was thrown.\n at System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()\n\n\nMy recommendation for converting larger sites on memory-constrained legacy hardware is, to choose the option to revert back to the web site model. Even after an initial success problem might creep up later.",


ninj 2009-07-15T20:15:09

Unless you have a specific need for a dynamically compiled project, don't use a web site project.\n\nWhy? Because web site project will drive you up the wall when trying to change or understand your project. The static typing find features (e.g. find usages, refactor) in Visual Studio will all take forever on any reasonably sized project. For further information, see the Stack Overflow question Slow “Find All References” in Visual Studio.\n\nI really can't see why they dropped web applications in Visual Studio 2005 for the pain-inducing, sanity-draining, productivity carbuncle web site project type.",


md adilahmed 2012-06-18T07:44:11

A \"web site\" has its code in a special App_Code directory and it's compiled into several DLLs (assemblies) at runtime. A \"web application\" is precompiled into one single DLL. ",


user4022749 2016-01-06T12:14:31

\nHere Web Supportive Application is an example of website.\nWebsite 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.",


M4N 2009-01-24T12:16:47

There is an article in MSDN which describes the differences:\n\nComparing Web Site Projects and Web Application Projects\n\nBTW: there are some similar questions about that topic, e.g:\n\n\nWeb Site vs. ASP.Net Web Application in Visual Studio note: was removed, no longer on SO\nwebsite or webapplication in.ASP.NET\n",


Chaturvedi Dewashish 2012-05-09T10:07:57

Website and Project>>website are two different methods of creating ASP.NET application using visual studio.\nOne is projectless and another is project environment. Differences are as\n\n\nSolution file is stored in same directory as root directory in project environment.\nNeed to remove solution and project files before deploying in project environment.\nComplete root directory is deployed in projectless environment.\n\n\nthere no much basic difference in using either approach. But if you are creating website that will take longer time, opt for project environment.",


Daniel Auger 2008-12-29T17:23:28

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.\n\nThe 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 under app_code since everything is dynamically compiled.\n\nThe web application model does not have dynamic compilation, but you gain control over the things that I have mentioned.\n\nIf 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.\n\nMore detailed analysis can be found in: \n\n\nWeb Application Projects and Web Deployment Projects are here\nWeb Site or Web Application?\n",


user1855471 2012-12-19T05:14:39

Web Application project model\n\n\nProvides the same Web project semantics as Visual Studio .NET Web\nprojects. Has a project file (structure based on project files).\nBuild model - all code in the project is compiled into a single\nassembly. Supports both IIS and the built-in ASP.NET Development\nServer. Supports all the features of Visual Studio 2005 (refactoring,\ngenerics, etc.) and of ASP.NET (master pages, membership and login,\nsite navigation, themes, etc). Using FrontPage Server Extensions\n(FPSE) are no longer a requirement.\n\n\nWeb Site project model\n\n\nNo project file (Based on file system).\nNew compilation model. \nDynamic compilation and working on pages without building entire site\non each page view.\nSupports both IIS and the built-in ASP.NET Development Server.\nEach page has it's own assembly.\nDefferent code model.\n",


More about “ASP.NET Web Site or ASP.NET Web Application?” related questions

ASP.NET Web Site or ASP.NET Web Application?

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...

Show Detail

ASP.NET Web Site or ASP.NET Web Application?

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...

Show Detail

ASP.NET Web Site or ASP.NET Web Application?

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...

Show Detail

ASP.NET Web Site or ASP.NET Web Application?

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...

Show Detail

Web Site or Web Application in ASP.NET

Which Visual Studio template should be used for a ASP.NET web site, the Web Site template or the Project | Web Application template?

Show Detail

ASP.NET with VS 2010: Web Site or Web Application?

When I start a new ASP.NET project in Visual Studio 2010, I can either create a new ASP.NET Web Site or an ASP.NET Web Application. What's the difference between these two project types? Why would I

Show Detail

using web site to develop or using web application in ASP.Net?

I want to learn the pros and cons of using Web Site project type or using ASP.Net Web Application Project type? My web application is using ASP.Net 2.0 or later, and the web application just shows...

Show Detail

ASP.NET Web site in Azure without converting it in to ASP.NET Web application

Is it possible to deploy ASP.NET Web site in Azure without converting it in to ASP.NET Web application? Is it possible then please provide some tutorial link ?I search but didn't found any link.Tha...

Show Detail

asp.net mvc 2 web application inside a Web site?

I have a Asp.Net Web Site deployed as a WebSite inside IIS 7.5. http://localhost/WebSite Then I have a second Asp.Net MVC 2 web application which is deployed as Sub Application inside the above

Show Detail

Is it possible to create a build definition for an ASP.net web site (not an ASP.net application) with TFS Build?

I have an legacy ASP.net website and would like to create an automated build with TFS Build. I have a lot of troubles with this while doing the same thing with an ASP.net web application works grea...

Show Detail