|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Web Application Projects Overview
The Web application project type is an alternative to the Web site project type, which is the default project type in Visual Studio 2008.
This topic contains:
The Web application project model lets you create a Web application whose structure and build semantics closely resemble the project model introduced with Visual Studio .NET 2003 applications. At the same time, the Web application project model provides all the features of Visual Studio 2008 and of ASP.NET version 2.0 and later. You might decide to use the Web application project model depending on your requirements and your preferred development workflow.
The default Web site project model uses the directory structure to define the contents of the project. In this model, there is no project file, and all files in the directory are part of the project.
In contrast, in a Web application project, only files that are explicitly referenced in the solution's project file are part of the project. These files are displayed in Solution Explorer, and they are the only files that are compiled during a build.
The project file of a Web application project makes some scenarios easier to implement. For instance, you can subdivide one ASP.NET application into multiple Visual Studio projects by referencing files in different project files. You can also easily exclude files from the project.
Use Web application projects when you want to do the following:
Migrate large Visual Studio .NET 2003 applications to Visual Studio 2008.
Have control over the names of output assemblies.
Use stand-alone classes to reference page classes and user-control classes.
Build a Web application by using multiple Web projects.
Add pre-build and post-build steps during compilation.
The Web application project model provides the same Web project semantics as Visual Studio .NET 2003 Web projects. This includes a structure based on project files and a build model that produces a single assembly. The Web application project model supports all the features of Visual Studio 2008, such as class diagrams, test development, and generics. It also supports features of ASP.NET such as master pages, data controls, membership and login, role management, Web Parts, personalization, site navigation, and themes.
The Web application project model removes the following requirements for projects that are created in Visual Studio .NET 2003:
Using FrontPage Server Extensions. These extensions are no longer required, but they are supported if a project already uses them.
Using a local copy of IIS. Web application projects support both IIS and the built-in ASP.NET Development Server.
Creating Web Application Projects
To use Web application projects, you must be using Visual Studio 2008 or Microsoft Visual Studio 2005 with Service Pack 1 (SP1) or Visual Web Developer Express. Visual Studio 2005 SP1 includes changes to Visual Studio 2005 that enable the Visual Studio Conversion Wizard and the designer to correctly process Web application projects. You can download Visual Studio 2005 2005 SP1 on the Microsoft Visual Studio Related Service Packs and Fixes Web site.
Compilation and Build Outputs
The compilation model for Web application projects resembles the Visual Studio .NET 2003 compilation model. All code files (stand-alone, code-behind, and class files) in the project are compiled into a single assembly and stored in the Bin directory. Because compilation creates a single assembly, you can specify attributes, such as assembly name and version. You can also specify the location of the output assembly if you do not want it to be in the Bin directory. For more information, see Compiling Web Application Projects.
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 are run in the browser.
When used with Web Deployment Projects, the .aspx files can also be compiled and included in a single assembly for deployment. For information about Web Deployment Projects, see the Visual Studio 2005 Web Deployment Projects page on the MSDN Web site.
Each time that you deploy the single assembly produced in this model, you replace the code for all pages in the project. For more information, see How to: Publish Web Application Projects.
Upgrade from Visual Studio .NET 2003
For most scenarios, it is better to upgrade existing Visual Studio .NET 2003 projects to Web application projects in Visual Studio 2008 than it is to use the Web site project model. The similarities between the Web application project model in Visual Studio 2008 and the Web site model in Visual Studio .NET 2003 simplify the upgrade process and minimize the need to restructure the application. For more information, see Walkthrough: Converting a Visual Studio .NET 2003 Web Project to a Visual Studio Web Application Project.