Differences between Web Site Project and Web Application Project

I have been working on both kinds of web projects since I started developing on ASP.Net. After manually migrating a Web Site into a Web Application Project, I now understand the differences:

Topic Web Site Web Application
Project Files All files in and below the project directory All files added to the .csproj project file
MasterPage Reference Add “Web Form” and check “Select master page” Add “Web Content Form”
Assembly Namespace Global namespace Namespace as defined in project
Generated assemblies Code in the App_Code directory compiles into a single assembly. Code from code-behind files compile into various assemblies named App_Web_*.dll. Assemblies can be merged using aspnet_merge. Compiles into single assembly
Code Restrictions Since code-behind is generated into randomly named assemblies, code in one page or control almost certainly cannot reference any other page or control. (Work-around: extract to base class or interface inside App_Code) Code under the App_Code directory is ignored. (Solution: rename App_Code directory)
Complete build Build from command line using aspnet_compiler Add aspnet_compiler as Post-build Event
Publish Publish from command line using aspnet_compiler and aspnet_merge Publish from command line using msbuild /property:OutDir=(path)
Published files Contents of aspx and ashx files is replaced by the text “This is a marker file generated by the precompilation tool, and should not be deleted!”. The Bin directory contains a (filename).(8hexdigits).compiled file for each compiled markup file listing the original dependencies. Original aspx, ascx, master files remain. ashx files refer to their implementation class.

4 thoughts on “Differences between Web Site Project and Web Application Project

  1. Pingback: Publishing Web Application Projects from the Command Line (VS2008) « devioblog

  2. Re: Published files, this is not accurate. You certainly can have the source .aspx files in a Web Site project in deployment. This is configurable in the Publish Web Site dialog (“Allow this precompiled site to be updateable”).

  3. Pingback: Registering UserControls in web.config, and Handling Nested UserControls « devioblog

  4. Pingback: The Evolution of Application Architecture « devioblog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.