This documentation is archived and is not being maintained.

Compiling Web Application Projects

The Web application project type provides an alternative to the Web site project type that was introduced in Microsoft Visual Studio 2005. The Web application project model is based on the Visual Studio .NET 2003 Web project model. It was created to simplify the conversion of Visual Studio .NET 2003 Web projects to later versions of Visual Studio and to reduce the need for code changes. Code files in the project are precompiled into a single assembly by using the Microsoft Build Engine (MSBuild). ASP.NET Web pages (.aspx) and user controls (.ascx) are compiled dynamically on the server by the ASP.NET compiler.


You can create ASP.NET Web application projects using Visual Studio or Visual Web Developer Express.

The compilation model for Web application projects resembles the Visual Studio .NET 2003 compilation model. All code files (stand-alone, code-behind, and designer class files) in the project are precompiled into a single assembly. By default, this assembly is built and persisted in the Bin folder. Because this compilation model creates a single assembly, you can specify attributes, such as assembly name and version. You can also specify the location of the output assembly. To change the location of the output assembly, in Solution Explorer, right-click the project name, click Properties, and then click the Build tab. On the Build tab is a field named Output Path where you can specify the path to the output assembly.

A Web application project is defined by a project file instead of by a project folder, as is done for a Web site project. The project file contains the files that are included in the project, and the assembly references and other project metadata settings. Files that are in the project folder but that are not defined in the project file are not compiled as part of the Web application project. Project settings that are added and changed through Visual Studio or Visual Web Developer Express are referenced in the project file (.*proj) that is generated for each project.

To run and debug pages, you must compile the complete Web application project. Building the complete Web application project can be fast because Visual Studio and Visual Web Developer Express use an incremental build model that builds only the files that have changed.

For more information, see Web Application Projects Overview.

Precompiling Class Files

Web application projects use MSBuild to precompile class files. These class files are compiled into a single assembly. By default, they are put in the Bin folder. You can extend and customize the compilation process by using standard MSBuild extensibility rules. For more information, see MSBuild Overview.

The following table describes the types of Web application project class files that are compiled into a single assembly.

Class File Type



Class files that you can create and add to the Bin folder.


User-defined code that directly relates to content files.


Code that is auto-generated. You should not modify the .designer file.

Customizing Compilation Options

You can specify the output assembly name, version, and other details by using elements of the Application property page of the Project Designer window. Use the Build page in the Project Designer window to specify the project's build configuration. For example, you can specify how errors are handled and specify details about the assembly output. In addition, you can add pre-build and post-build steps during compilation by setting values of the Build Events property page. For more information about property pages, see Projects, User Interface Elements.

By default, only class files of Web application projects are compiled by MSBuild when the Build Action property is set to Compile. However, if a Web application project includes class files in the App_Code folder, those class files will be compiled by the ASP.NET compiler. This is true even if their build action is not explicitly set to Compile.


The App_Code folder exists for Web site projects in Visual Studio 2005. This folder is not typically included in Web application projects. For more information about the App_Code folder, see Shared Code Folders in ASP.NET Web Sites.

Although code files in the project are precompiled into a single assembly by using MSBuild, ASP.NET Web pages (.aspx) and user controls (.ascx) of a Web application project are compiled dynamically on the server by the ASP.NET compiler. In a Web application project, Web pages and user controls can use the CodeBehind attribute and the Inherits attribute in their @ Page or @ Control directives. The CodeBehind attribute references the code-behind file to use. The Inherits attribute points to a namespace and class in the code-behind file. 

In Web application projects, you can make limited changes to the ASP.NET Web pages in your site after they have been compiled and deployed. For example, you can change the arrangement of controls, colors, fonts, and other appearance aspects of pages. When the site first runs, ASP.NET performs additional compilation in order to create output from the markup.

You can declare a control statically in the code behind file as long as you make it protected or public. Because the .aspx page inherits from the code behind file, it will use that declaration and not declare a new one. Moving the declaration of a control to the code-behind file is useful in the following situations:

  • When the type of the control must be derived from a standard type.

  • When you want a scope for the control other than the default scope. Scope refers to accessibility level, such as public, private, internal, protected and protected internal.

  • When you want to add metadata attributes to the declaration of the control.

  • When you want to write XML code comments for the declaration of the control.

For more information about how to add controls, see How to: Add Controls to an ASP.NET Web Page Programmatically.

Because all class files are compiled into a single assembly, only that assembly has to be deployed, together with the .aspx and .ascx files and other static content files. In this model, .aspx files are not compiled until they requested by the browser.

However, you can also compile .aspx files and include them in a single assembly for deployment. You can do this by using Web Deployment Projects, which is a downloadable add-in to Visual Studio. To download this add-in, see Visual Studio 2005 Web Deployment Projects on the ASP.NET Developer Center Web site. For more information about how to deploy Web application projects, see How to: Publish Web Application Projects.