The introduction of a new version of a platform is always accompanied by lots of press and often excitement over much-anticipated features. Developers love to build applications with new technology, but there is often pain when moving existing, proven applications from older versions to the latest-and-greatest.
This week I examine some of the issues you may encounter when moving Web applications built with ASP.NET 1.1 to the new 2.0 model.
The latest version of ASP.NET, 2.0, is more than an upgrade—it is a major update of the technology, as it changes the way ASP.NET applications are designed, compiled, and deployed. Microsoft does recognize the existence of a large number of ASP.NET 1.1 installations, so 2.0 was designed to allow older applications to work without problems. On the other hand, the need to convert existing applications to the 2.0 platform may arise. With that said, let's examine the major differences between the versions, as well as areas that may be problems during the conversion process.
While there are many changes between ASP.NET 1.1 and 2.0, there are certain ones that have a greater impact of project conversion. The following list provides an overview of the key issues:
- Code-behind model: ASP.NET 2.0 introduces the concept of partial classes, whereas a class can span multiple class files. It is a key feature used in Visual Studio 2005 to separate system-generated code from user code. This negates the scenario where you find yourself scrolling through source code and encountering the code generated by the system. The partial class approach reduces the risk of inadvertently editing system code and results in smaller code-behind files.
- Directories: ASP.NET 2.0 has added a number of special directories where 1.1 had only the one required bin directory. Most of these new directories have the App_ prefix with names like App_Code, App_Data, App_GlobalResources, and App_LocalResources, while the bin directory still exists along with a themes directory. The new directories are a key aspect of 2.0's elimination of project files.
- No more project files: Gone are the days of project files with ASP.NET and Visual Studio 2005. The project is now the complete Web project directory, which is a drastic shift from 1.1 and can cause migration issues as described later.
- Compilation model: With 1.1, all code was compiled into one assembly placed in the bin directory. With 2.0, the assembly is separated into multiple assemblies. These multiple assemblies may be created on-the-fly or precompiled. Examples of multiple assemblies are one assembly for each ASP.NET directory like App_Code and App_Data as well as individual assemblies for Web Forms, User Controls, and so forth. This is a major shift in the application structure; it offers more deployment options in how the application is delivered to the users.
- Application deployment: The deployment of 1.1 applications was fairly straightforward as you moved the content files along with the necessary assembly files—it could easily be accomplished with a simple copy and paste with limited options. The 2.0 model provides various options for deploying an application. For instance, you may choose to precompile all code and deploy it or go the other way with no precompilation. Also, you can lock down deployed content files so no changes may be made after deployment (this is a major difference from 1.1).
The list provides a high-level view of the main differences between ASP.NET 1.1 and 2.0 and what can affect the conversion of an existing application to 2.0. Now let's take a closer look at possible problem areas.
The major differences covered in the previous section provide clues of where you may experience problems when converting an application. The following list highlights areas where you need to be careful when moving an application to the new ASP.NET 2.0 platform:
- You should be certain the application compiles with no problems with 1.1 before starting the conversion process. With a fully functional project, make a backup and then start the conversion.
- 2.0's obliteration of the project file is a drastic shift from 1.1. With 2.0, all references have been moved to their own directories. In addition, the Web project folder is now the project so older 1.1 projects with multiple sites will need to be split into separate projects with 2.0. You'll need to separate the projects before converting them.
- The new directory structure in 2.0 requires resources and other components used in 1.1 that you will need to shift to the new directories.
- The new compilation structure with multiple assemblies generated will likely change the way the application is deployed, so be aware of the different assemblies when deploying the converted application.
- The .NET Framework has changed from 1.1 to 2.0, so there may be features of 1.1 that are no longer supported in 2.0 (like classes or their methods and/or properties).
Follow the wizard
Microsoft does not leave you in the cold when approaching a conversion project. Visual Studio 2005 includes a conversion wizard to walk you through the conversion of a project.
The Visual Studio Conversion Wizard begins by offering to make a backup of the existing application before proceeding (which is a very good idea). Next, it proceeds with conversion and presents a log of the process when it has completed. Common issues that may arise involve features of the .NET Framework that may have been replaced or removed in the latest version. Listing A is an example of one of these issues.
This message in Listing A tells me a feature has been replaced by another feature in the latest platform version, so I must manually make the change to the code. Depending upon the application, there may be numerous issues along these lines. You'll need to address each issue individually and make the necessary changes to fully take advantage of the 2.0 platform.
Take your time
As with any conversion process, the best approach is to be slow and methodical. There is no need to rush the process. The ASP.NET 2.0 platform provides a number of new features that make it easy to build powerful solutions, but you must consider these changes when transitioning older ASP.NET 1.1-based applications to the new platform. Keep the changes discussed in this article in mind and take advantage of the conversion wizard to slowly move to the new environment.
Miss a column?
Check out the .NET Archive, and catch up on the most recent editions of Tony Patton's column.
Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.
Tony Patton has worn many hats over his 15+ years in the IT industry while witnessing many technologies come and go. He currently focuses on .NET and Web Development while trying to grasp the many facets of supporting such technologies in a production environment on a daily basis.