Tip

ASP.NET 1.x to ASP.NET 2.0 migration in five steps

The out-of-the-box ASP.NET migration tool in Visual Studio 2005 is the Web Site Project, which is based on the dynamic compilation model. Microsoft learned shortly after the release of VS 2005 that the Web Site project required some manual code fixes and was a bit cumbersome for large Web projects.

To that end, Microsoft released the Web Application Project in May 2006. This is based on the client project model, and it compiles into a single assembly while allowing multiple configurations, said Omar Khan, group program manager for Visual Studio Web Tools.

The Web Application Project, or WAP, was included in Visual Studio 2005 Service Pack 1. Microsoft's Visual Studio 2005 Web Application Projects page provides information on what developers should do if they have not installed VS 2005 SP 1 or still have the separate WAP add-on.

Though developers could update a Web application's script map to ASP.NET 2.0 and still develop using Visual Studio 2003, Khan said Microsoft recommends migrating using WAP. "We definitely feel this is the path of least resistance, and it gives you all the benefits of ASP.NET 2.0 within the IDE," he continued.

At Tech Ed 2006, Khan provided a five-step process for migrating Web projects from ASP.NET 1.x to ASP.NET 2.0. If a project is error-free in Visual Studio 2003, then a developer can migrate in less than 30 minutes with "very little manual steps required," Khan said.

Make sure the Web Application Project is available. As stated, this was included in Visual Studio 2005 Service Pack 1.

Validate the application in Visual Studio 2003. Open the application in VS 2003, perform a build and validate all projects and page functions. Khan also suggested running the app in the browser to check for errors in ASPX files.

More on ASP.NET migration

ASP to ASP.NET Migration Learning Guide

Microsoft's Web Application Project released

Microsoft updates VS 2005 Web Application Project

This step should solve a common problem on the MSDN forums, where many developers report issues with a migration, only to discover that the cause is, in fact, a flaw in the original code.

Open Visual Studio 2005 and launch the Conversion Wizard. It's best to migrate an entire solution at once, but if you plan to do individual projects, then start with "bottom of the food chain" items like class code and shared libraries, Khan said. Once the wizard has run its course, perform a build.

Errors that may need fixing at this point include in-line VB code in ASPX pages and name collisions. The latter occur when VS 2003 types don't quite fit into the corresponding default namespace in Visual Studio 2005, and they can be remedied by fully qualifying the namespace, Khan said. Once errors have been cleaned up, run the application and validate its functionality.

Convert to partial classes. One of Visual Studio 2005's many new features is partial classes, which separates a developer's code-behind file from the designer file that Visual Studio creates. (These files come together at compile time.) To convert the pages in your application to partial classes, right-click on the root mode of a Web project and select "Convert to Web Application. This will move generated code into a designer.cs or designer.vb file, depending on the language you are using.

As in Step 3, the next task is performing a build and correcting the errors that arise. In this case, Khan said, the error is likely to be a missing control declaration. This can be added to either the designer file or the code-behind file; Khan recommended the code-behind file, since it changes only at a developer's discretion.

Fix up XHTML errors, if desired. In VS 2003, the default validation for a Web application is the IE 6 schema. Developers can leave validation for a migrated application on IE 6 or, through the Tools option, change the validation to XHTML, open the app's individual pages and correct and errors. Khan cautioned that this can be a lengthy process.

As an aside, Khan offered developers one additional consideration. Some types have been deprecated in Visual Studio 2005, meaning the types are fully supported now but will not be in future versions of Visual Studio. During a migration from ASP.NET 1.x to 2.0, a developer may see a set of errors for deprecated classes and recommendations for alternate classes. A fix is not necessary for ASP.NET 2.0, but, Khan said, "you'll definitely run into a point where it won't compile."

This was first published in June 2006

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.