Reddnet Scribbles

It makes me want to gouge my eyes out with a cheese grater!

asp.net - Web Site vs. Web Application

Stephen M. Redd
Thursday, November 01 2007

For more info, see my follow-up article: ASP.NET: web site vs. web application project - Part 2 


A few years ago, when I first got a look at asp.net 2.0, it was clear to me that there must have been some serious changes inside the development team at Microsoft. ASP.NET 1.x was a huge leap forward in server side web application frameworks, but it was also geared to an object oriented audience. While it did support direct data access from web pages and everything-in-one-file styles, Visual Studio's use of asp.net encouraged a more tiered design with clean separation of presentation, business, and data access. It also encouraged OO  design by making inheritance, namespaces, and assemblies all obvious, simple, and the default way of things.

By the time asp.net 2.0 was coming out,  more agile languages were getting all the buzz. PHP was still relevant and Ruby on Rails was shaping up to be the next big contender. By that time Java's JSP, the only other heavy OO platform that still mattered, had fallen flat on its face. So it wasn't exactly a surprise that there was a focus within asp.net 2.0 towards the "less is more" philosophy of quick, dirty, do-what-I-mean design. Codeless databinding, master pages, skins, themes, and configuration driven providers for common stuff like membership, profiles, personalization, etc. were all expected.

But what make several of us step back was the new compilation model and the "project-less" web site... er... project. Aside from being one of the most impossible to name mechanisms, it was also a breaking change in how asp.net was done. The new compilation model threw out the visual studio project file itself, took asp.net back to the "compile-on-the-fly" concept, all but eliminated the use of namespaces within a web site, and radically altered the way UI template and the associated code-behind were arranged.

But for those of us doing serious web frameworks in large or complex environments, the web site model had some serious drawbacks. The biggest for me was having to manually deal with namespaces, which the UI and code designers would fight every step of the way (until you finally gave up and just let it pile up in one big default namespace). The loss of the visual studio project files was also painful, and it lead to an awkward "exclude from project" mechanism where the only way to get Visual Studio to ignore a file was to physically rename it. Large web sites with lots of code suffered horribly in performance because so many helpful visual studio features, like refactoring and the verification compiler had to sift through every file in the project with no guidance from project configuration.

Microsoft seemed to notice the problem, and resurrected the old project model in what they called the "Web Application" Project. This was essentially a retro-fitted clone of the old project model complete with designer generated code files (updated to take advantage of partial classes though). The new project type brought back namespaces, and once again encouraged clean OO design patterns. It also became apparent over a very short time that Microsoft itself would consider the web application model the new "enterprise" project type while the web site project type was more for the beginner and casual developers. For example, Team system's testing, build, and deployment work great with the web application project, but work poorly if at all with web site projects. But the new project type also brought with it the need to compile everything in advance, and used a different mechanism to associate UI and code-behind files that was incompatible with dynamic compilation.

With Visual Studio 2008 Microsoft is keeping both project types. But I think they are missing an opportunity. While the web application project and web site projects both have advantages and disadvantages, there doesn't seem to be a compelling reason for some of the features to be mutually exclusive.

I for one would love to see a hybrid project type. Keep the project file to organize the site and give us a place to put visual studio specific settings. But switch it use the dynamic compilation model from web site projects. Dynamic compilation and xcopy deployment were powerful ideas, and I can't see any reason they can't be used still. The verification compiler can be optimized quite a lot by having access to a project file... exclusions can be dealt with elegantly, and the whole thing can be sped up. For other code though, you could choose to continue to compile to an assembly in advance, or leverage the app_code folder for dynamic compilation, or a combination of both. And of course, keep the namespaces and configurable compiler options.

I'd love to see a web project type that keeps the best of web site and web application projects both. Give me control over the project's structure, namespaces, and compilation but also give me xcopy deployment, dynamic compilation (using my settings), and keep a consistent way of associating an asp.net UI file to its code-behind without requiring the designer generated code file and full compilation.

Oh well, maybe in the next release.

Stephen M. Redd
Thursday, November 01 2007
Filed under: Code
Tagged as: , ,
13 Comments

» Trackbacks & Pingbacks

    No trackbacks yet.
Trackback link for this post:
http://reddnet.net/trackback.ashx?id=170

» Comments

  1. John avatar

    Never worked with Web Projects as I started working in VS2005 and the only thing available to me was ASP.NET website module ....but after reading this article I am going to give a try to web project in freshly installed VS 2008.

    Thanks for the wonderful article...

    John — February 19, 2008 1:07 PM
  2. Morris Huner avatar

    Nice article. Helpful as I'm cranking up on a Visual Studio 2008 project.

    Morris Huner — February 26, 2008 1:44 PM
  3. Kyle avatar

    Great article. I love how you hilight the "types" of people who use web SITES over applications.

    I'm a web app man, but I've seen some script-kiddie'ish web "applications" that are piles of unmaintainable nonsense thanks to the "site" programming model...

    I kind of agree with the hybrid model, but I gotta share an anecdote about dynamic compilation. Dynamic compilation leads greenhorn (or lazy, which is more often what I've witnessed) programmers to post code into staging (or worse - production) with BASIC COMPILATION ERRORS (syntax, type safety, etc.)

    Yeesh! Guys, we have compilers for a reason! I hate it when developers waste their time on basic syntax nonsense when there's a compiler that is supposed to catch those issues BEFORE staging and testing...

    Script languages have no choice but to be "interpreted-on-demand", but ASP.NET has NO excuse...

    Kyle — October 31, 2008 2:12 PM
  4. Jef Claes avatar

    Thanks for the article! Webapplications for the win imo.

    Jef Claes — November 11, 2008 7:48 AM
  5. Pankaj avatar

    Nice article...Good work..

    Pankaj — December 25, 2008 2:06 PM
  6. Dhananjay Goyani avatar

    When I moved from VS 2003 to VS 2005, the only choice I had was Web site project. Well, I was not prepared for the change as I have extensively used web application project. I felt literally lost.

    Fortunately others including MS devs too felt lost and they released WAP plug-in for VS 2005. When 2008 was announced, very firstly I checked what they kept/thrown from web templates. Lol, WAP is there. ;-) ScottGu in one of the post mentioned that 2010 would also have WAP.

    Anyways, you have described the difference nicely.

    Thanks!

    Dhananjay

    Dhananjay Goyani — January 20, 2009 4:50 AM
  7. Dan avatar

    Nice Topic

    webhost4life.org

    Dan — March 5, 2009 2:28 PM
  8. S.Muhilan avatar

    Hi

    We can use web application project module in VS.NET 2005 also by downloading installing VS.NET 2005 web application setup.

    S.Muhilan — March 22, 2009 10:25 AM
  9. ricky avatar

    Great post, always fun reading your stuff!

    ricky — May 10, 2009 5:34 PM
  10. bestes Internet Casino avatar

    I went ahead and tried to install the new VS2005 beta I picked up at VSLive this week. Unfortunately I haven’t had much luck with it – it killed all of ASP. Net and worse the IIS Management Console. It looks like there’s a failure registering various virtual directories under ASP. Net 2.0. But the real bummer is that it crashes the IIS Admin console. As soon as I bring up the management console and right click on a Web site the MMC blows up with an exception. Trying to run an existing ASP.Net application results in immediate 404 errors

    bestes Internet Casino — May 23, 2009 6:20 AM
  11. Ed Hastings avatar

    Good article; a hybrid project type would be a great thing indeed.

    Ed Hastings — June 1, 2009 3:20 PM
  12. robert avatar

    very great article, thanks for shared

    robert — June 15, 2009 9:10 PM
  13. Vegas online casino gambling games avatar

    When I first started with ASP.NET I used Web Site model because it made more sense to me. Now that I've spent the time to understand it I don't really see a reason to ever use Web Site model again. I don't mind rebuilding between changing or uploading a fresh .DLL.

    Vegas online casino gambling games — June 27, 2009 6:24 AM

» Leave a Comment