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. |
Pingback: Publishing Web Application Projects from the Command Line (VS2008) « devioblog
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”).
Pingback: Registering UserControls in web.config, and Handling Nested UserControls « devioblog
Pingback: The Evolution of Application Architecture « devioblog