Export (0) Print
Expand All

Walkthrough: Converting a Visual Studio .NET 2003 Web Project to a Visual Studio 2005 Web Application Project

By converting your Visual Studio .NET 2003 Web project to a Visual Studio 2005 Web application project, you can take advantage of all the new features of Visual Studio 2005, such as refactoring, class diagrams, test development, and generics. The Web application project model also makes available all the new features of ASP.NET 2.0, such as master pages, data controls, membership and logon, role management, Web Parts, personalization, site navigation, and themes. Also, the Visual Studio 2005 Web application project model more closely matches the project model available for Visual Studio .NET 2003 applications, which may be ideal for Web developers who are converting a Visual Studio .NET 2003 Web project to Visual Studio 2005. For more information about new features, see What's New in Web Development for Visual Studio and What's New in ASP.NET.

This walkthrough explains the process of converting an existing Visual Studio .NET 2003 Web project to a Web application project in Visual Studio 2005. The Web application project model uses the same conceptual approach as a Web project in Visual Studio .NET 2003. This includes a project file to include and exclude files, and compilation to a single assembly. For more information, see Web Project Conversion from Visual Studio .NET.

NoteNote

To convert a Web site that uses FrontPage 2003 from Microsoft to a Web application project, first convert the FrontPage Web site to a Visual Studio 2005 Web site project, and then convert the Web site project to a Web application project. For more information, see Walkthrough: Converting a Web Site Project to a Web Application Project in Visual Studio 2005.

Tasks illustrated in this walkthrough include the following:

  • Opening and verifying your Visual Studio .NET 2003 Web project.

  • Backing up your Visual Studio .NET 2003 Web project.

  • Converting your Visual Studio .NET 2003 Web project to Visual Studio 2005.

  • Verifying the Web application project in Visual Studio 2005.

  • Converting code-behind classes to partial classes.

  • Examining and resolving XHTML-compliance issues.

In order to complete this walkthrough, you will need:

  • Visual Studio .NET 2003

  • Visual Studio 2005 Service Pack 1 (SP1)

  • The .NET Framework version 2.0

Before converting a project, open your existing Visual Studio .NET 2003 solution. Next, compile and run the solution to verify that everything works as expected.

NoteNote

In Visual Studio .NET 2003, the files that make up the project are included in a solution file (.sln).

To open and verify your Visual Studio .NET 2003 Web project

  1. On the File menu, click Open File, and then type or browse to the .sln file for the solution that you want to verify.

  2. On the Project menu, click Build Solution.

  3. On the Debug menu, click Start.

  4. Verify that your project runs as expected.

Make sure that you back up your Visual Studio .NET 2003 solution and project files before you start the conversion process. If any conversion issues occur, you can revert to your Visual Studio .NET 2003 solution. Copy your project in Visual Studio .NET 2003 before you begin the conversion process. Alternatively, you can back up your project by using the Visual Studio Conversion Wizard when you are ready to convert your project to Visual Studio 2005.

To back up your Visual Studio .NET 2003 Web project before conversion

  1. Open Visual Studio .NET 2003.

  2. On the File menu, click Open File, and then type or browse to the .sln file for the solution you want to back up.

  3. On the Project menu, click Copy Project.

  4. In the Copy Project box, select Destination project folder.

  5. Select a Web access method option. You can use either FrontPage or File share to copy the files.

  6. Select the Include all files in the project folder option and then click OK.

Visual Studio 2005 converts your Visual Studio .NET 2003 solution and the project files it contains to use the Microsoft Build Engine (MSBuild) format, which is the new project file format in Visual Studio 2005.

As part of the conversion process, Visual Studio 2005 generates an XML-based log file that provides a summary of the conversion, flagging any issues. By default, the conversion log file is saved in the same directory as the .sln file. If you later have problems when compiling the project, you can refer back to the conversion log file.

To convert your Web project to Visual Studio 2005

  1. Close the solution file in Visual Studio .NET 2003, and open Visual Studio 2005.

  2. On the File menu, click Open File, and then type or browse to the .sln file for the solution that you want to convert. The Visual Studio 2005 Conversion Wizard opens.

  3. Click Next, follow the instructions to complete the wizard, and then click Finish.The conversion process begins.

After the solution and project files are converted to the Visual Studio 2005 format, validate that your application builds without errors and runs as expected.

To verify the Web application project in Visual Studio 2005

  1. On the File menu in Visual Studio 2005, click Open File, and then type or browse to the .sln file for the solution you want to verify.

  2. On the Project menu, click Build Solution.

  3. On the Debug menu, click Start.

  4. Verify that the Web application project runs as expected.

Common Errors and Warnings

The most common types of errors or warnings are as follows:

  • Conflicts with names introduced in the .NET Framework version 2.0.

  • Warnings about using obsolete members.

  • Issues when running the Web application.

To fix naming conflicts, you can either remove ambiguity by fully qualifying existing names with a namespace or rename the members so that they do not conflict. For more information about naming conflicts, see ASP.NET 2.0 Migration Overview and Namespace Naming Guidelines.

If you see a warning about using obsolete members, the warning message will often suggest alternative APIs to use. In these cases, you can continue to use the obsolete members in version 2.0 of the .NET Framework. However, the members will be removed in the next major release of the .NET Framework, so it is a good practice to remove the members and substitute the suggested alternatives.

If you see a "Directory Listing Denied" error while running your Web application, your Web application's virtual directory might not allow its contents to be listed. To fix this issue, right-click the application's start page in Solution Explorer and then click Set as Start Page to make sure that the correct page is invoked when the application runs.

In Visual Studio 2005, Web application projects use partial classes to store designer-generated code. These classes are stored in a separate file from the code-behind file. By default, the Visual Studio 2005 Conversion Wizard does not create a *.designer.cs file or a *.designer.vb file for Web pages (.aspx files) or user controls (.ascx files). Instead, the code will look and work just like it did in Visual Studio .NET 2003.

NoteNote

The Visual Studio 2005 Conversion Wizard will make the minimum number of changes to the code files during the conversion process. This helps ensure a smooth conversion to a Web application project in Visual Studio 2005.

You can keep your code in the Visual Studio .NET 2003 format. If you do, you must manually update the control field declarations in the code-behind files like you did in Visual Studio .NET 2003. However, to take advantage of the ability to maintain field declarations in generated code, you should update your pages and controls to use the partial-class model introduced in ASP.NET 2.0. Partial classes make it easier to organize the generated code and custom code for your code-behind files. For more information, see Partial (Visual Basic) and partial (C# Reference).

To convert your code to use the partial-class model

  1. Make sure your code compiles without errors.

  2. In Solution Explorer, right-click the project name and click Convert to Web Application.This command iterates through each page and user control in the project, moves all control declarations to a .designer.cs file, and adds event handler declarations to the server-control markup in the .aspx and .ascx files.

  3. When the process has finished, check the Task List window to see whether any conversion errors are reported. If the Task List displays errors, right-click the relevant page in Solution Explorer and select View Code and View Code Gen File to examine the code and fix problems.

    NoteNote

    Errors and warnings that appear in the Task List window persist between Visual Studio sessions. After you have fixed errors listed in the window, you can clear items from the task list.

  4. Recompile your project to make sure that it compiles without errors.

Another way to convert your code to use the partial-class model is to use the Convert to Web Application command on individual pages. You might do this first on a few pages so you can see the changes that were made for each page before applying the changes to the whole application.

The Convert to Web Application command cannot be undone in Visual Studio. The best method for restoring the changes is to restore from a backup of the Visual Studio .NET 2003 project, and then to re-run the Visual Studio 2005 conversion as described earlier.

From this point, when you add new pages to the Web project, the pages will use the partial-class template by default. For more information, see ASP.NET 2.0 Migration Overview.

By default, Visual Studio 2005 generates and validates XHTML-compliant markup. This helps you build Web applications that are standards compliant and helps minimize issues with browser-specific rendering. Visual Studio .NET 2003 did not generate XHTML-compliant markup. Therefore, after converting your Web application to Visual Studio 2005, you might see validation and rendering issues with pages that were created in Visual Studio .NET 2003.

NoteNote

Validation errors are informational only and are flagged as warnings. Validation errors do not prevent a page from running.

If you want to see HTML validation errors as you did in Visual Studio .NET 2003, switch the HTML validation setting from XHTML Transitional to Internet Explorer 6.0. Internet Explorer 6.0 was the Visual Studio .NET 2003 default setting for HTML validation. For more information, see How to: Select Validation Schemas for HTML Editing in Visual Web Developer.

You can also add the following section to your project's Web.config file, which causes ASP.NET to render legacy (non-XHTML compliant) markup from server controls:

<system.Web>

<xhtmlConformance mode="Legacy" />

</system.Web>

This will avoid the small rendering differences you might see between pages displayed using ASP.NET 1.1 and using ASP.NET 2.0. However, use the previous xhtmlConformance mode change to resolve any conversion issues. Once the Web application project is running correctly, remove the legacy configuration setting. For more information, see ASP.NET and XHTML and ASP.NET 2.0 Migration Overview.

Community Additions

ADD
Show:
© 2015 Microsoft