ASP.NET

Web Site project vs Web Application project in Visual Studio

ASP.NET · · Published 2026-09-22

Visual Studio offers two templates for ASP.NET on .NET Framework: ASP.NET Web Site (File › New › Web Site) and ASP.NET Web Application (File › New › Project). The pages look identical, but how the code is compiled and deployed differs, and mixing up the two explains many deployment errors.

Main differences

Web Site projectWeb Application project
Project fileNone; the folder is the project.csproj lists every file
Page directiveCodeFile="Default.aspx.cs"CodeBehind="Default.aspx.cs"
CompilationOn the server at run time (or precompiled at publish), often one assembly per folder or pageAt build time into one assembly in bin
DeployCan copy source files; ASP.NET compiles themDeploy the DLL and markup, not the .cs files
Shared codeMust live in App_CodeAnywhere in the project
Designer fileGenerated on the fly.aspx.designer.cs holds control declarations
NamespacesPages often have noneStandard project namespaces
Build events, references, MSBuild customisationLimitedFull

Consequences

Which is best?

For anything maintained by a team or deployed through a pipeline, the Web Application project. Microsoft's own Web Forms templates and tutorials use it, and it is the model that tools such as NuGet, MSBuild and publish profiles assume. The Web Site model remains supported for existing sites.

Converting a Web Site

  1. Create an empty Web Application project and copy the site's files into it.
  2. Move App_Code classes to a normal folder (code in App_Code would be compiled twice).
  3. Right-click the project and choose Convert to Web Application. Visual Studio changes CodeFile to CodeBehind and generates the designer files.
  4. Add namespaces, fix references, build and test every page.

Spotting the type of an existing project

Open the folder: a .csproj or .vbproj file and .designer.cs files mean a Web Application; their absence, an App_Code folder and CodeFile= in page directives mean a Web Site. In Visual Studio, a Web Site appears in Solution Explorer with a path as its name and has no "Properties" node with build settings. Knowing which one you have tells you what to deploy and why a page may compile on one machine and not on another.

Official documentation