Upgrading from Stock Projects
Upgrading a stock project to WAP involves creating a new WAP project and then copying the old site's files into the WAP project. The easiest way to do this is to use Explorer to drag-and-drop the files from the old project directly into the WAP project in Solution Explorer. You have to rename the APP_CODE
folder because WAP doesn't support it. You also have to convert all markup pages that contain any CodeBeside code. After you have copied the files to the new project, use the "Convert to Web Application" option on the Project menu to convert a single file, a folder, or the entire project to a WAP project. The conversion goes through each stock project page and fixes up the @Page
directive, converting the CodeFile
attribute to a CodeBehind
attribute and creating the .designer
file that holds the control definitions.
It's a fairly smooth process, although you may run into a page here or there that doesn't want to convert. Before you move files over for conversion, make sure your project compiles properly in stock projects because the conversion relies on resolving references and dependencies to figure out how to upgrade them.
Options are Good
Any way that you look at it, compilation in ASP.NET has some complexities. I hope this article has given you some deeper insights into the compilation and deployment process. ASP.NET 2.0 has brought some improvements as well as some steps backward in this area, but most of all it offers more options. Usually options are good, but I think in this case the choices can be overwhelming. The problem is worsened by the fact that the stock project model seems easier to use and doesn't reveal some of its problems until later in a typical Web development process, such as when a site is refactored and ready to deploy. So watch out for the gotchas, and start thinking about these issues early on in the project.
Currently, I prefer to use Web Application Projects whenever I can for any serious work. To me, Web Application Projects bring sanity to the Web development process with a predictable and consistent project and compilation mode that was lacking with stock projects. I've worked with stock projects for over a year now and I've just hit too many dead ends in this model to feel comfortable with it. Although WAP is a bit more rigid than stock projects when it comes to configuration and explicit compilation, I'll take the more logical and quick compilation, simple inheritance model, and single assembly output any day over the somewhat unpredictable stock project model.
But that doesn't mean that WAP is for everybody. If you're working with stock projects, not running into any problems, and you can live with the deployment issues, there's no need to switch to WAP. The file-based model using its "Edit and Go" model for running applications is appealing and make stock projects more easygoing and productive. And if you do use stock projects and run into a dead end, you can easily switch to WAP. I will continue to use stock projects for demos and samplesit really can't be beat for that because of its portability. Even if you are perfectly happy with stock projects, I would still recommend that you check out Web Deployment Projects to simplify deployment-it's a no-brainer to use this tool unless your applications are very small.
Please keep in mind that both Web Application Projects and Web Deployment Projects are available only for Visual Studio-they don't work with Visual Web Developer.