Web Site vs Web Application Project (WAP)
In ASP.NET 1.x there was only one way to create a web app—the Web Application Project (WAP). In ASP.NET 2.0 WAP was killed, deliberately or not, and replaced with the lame Web Site “model.” WAP for Visual Studio 2005 was shipped separately later.
There are several reasons I strongly dislike Web Site projects.
Sloppy project structure
This model encourages sloppy project organization. A typical web site has no structure. You’re lucky if you see a namespace here and there. In my opinion, this is unacceptable. Since less competent developers simply use what comes out of the box, Web Site is a “bad practice” from the get-go.
Not long ago, I took over a project from someone who had everything dumped into a single Web Site. There were no logical or physical tiers. A Web Site has no solution file per se, so the guy made no effort to separate concerns.
to MSDN, “You can store source code in the
App_Code folder, and it will be automatically compiled at run time.” In real life, I see that
App_Code is a garbage can where people throw code they don’t know where to put. Instead of thinking through which namespace a class should go to (logical organization), or even which folder (physical ogranization),
App_Code serves as a dumpster.
There’s a whole bunch of other magic folders I’m not comfortable with.
Please note: this isn’t a discussion about convention vs configuration. It’s not like you can rename
App_Code or stop its on-the-fly compilation. It’s imposed on you.
You don’t learn the true meaning of pain until you have to migrate a decent-size Web Site to a WAP. There’s no automatic migration. It’s all manual and very painful. I don’t want to belabor the point. Scott Guthrie and Mohamed Meligy have lengthy instructions. I had to go through a migration ordeal recently, and it wasn’t fun at all.
Beware of the following side effect: conversion to WAP resets AutoEventWireup.
The bin folder
Again, MSDN states, “You can store compiled assemblies in the Bin folder.” I inherited a project where all dependencies where simply dumped into bin. Another dumptser. In a WAP, you don’t mess with bin. You set references and they are copied into bin when the project is built.
When you migrate a Web Site to a WAP, you have to go and clean out the bin folder by hand.
In my no-so-humble opinion, the ASP.NET Web Site model is an aberration. I wish Microsoft retired it as a failed experiment.