Sdílet prostřednictvím


Walkthrough: Converting a Visual Studio 2005 Web Site Project to a Visual Studio 2008 Web Application Project

This walkthrough describes how to convert a Visual Studio 2005 Web site project to a Visual Studio 2008 Web application project. The Visual Studio 2008 Web application project model is like the Visual Studio 2005 Web application project model, a feature that was introduced in .NET Framework 2.0 SP1. For more information Web application projects, see Web Application Projects Overview 

Note

If the Web site is based on Microsoft ASP.NET AJAX, the conversion process requires additional steps beyond this walkthrough. For more information, see How To: Upgrade an ASP.NET AJAX 1.0 Web Project to .NET Framework 3.5.

This walkthrough demonstrates the following tasks:

  • Opening the Visual Studio 2005 Web site in Visual Studio 2008.

  • Upgrading the .NET Framework version that the project targets.

  • Creating a new Visual Studio 2008 Web application project.

  • Copying the Visual Studio 2005 Web site files to the new Visual Studio 2008 Web application project.

  • Converting ASP.NET code files.

  • Testing the converted project.

Prerequisites

To complete this walkthrough, you will need:

  • Visual Studio 2008.

  • A Web site that was created in Visual Studio 2005 that compiles and runs without errors.

Converting the Web Site

To begin, you open the Web site in Visual Studio 2008, which starts the conversion.

To convert the Web site

  1. In Visual Studio 2008, in the File menu, click Open and then click Web Site.

    The Open Web Site dialog box is displayed.

  2. Browse to the folder that contains the Web site files, and then click Open.

    Visual Studio 2008 prompts you to upgrade the targeted version of the .NET Framework for the project.

  3. To upgrade to the .NET Framework 3.5, click Yes.

    Note

    You can also change the target version of the .NET Framework manually later by using the project property pages.

Testing the Converted Web Site

After the conversion has finished, you can test the project to make sure that it runs. This will also help you identify code in the project that must be updated.

To verify that the Visual Studio 2005 Web site compiles and runs

  1. If you know about changes that are required for the code to run with the new version of the .NET Framework, make those changes.

  2. On the Build menu, click Build Web Site.

  3. On the Debug menu, click Start Debugging.

    If debugging is not enabled, the Debugging Not Enabled dialog box is displayed. Select the option to add a Web.config file that has debugging enabled, and then click OK.

    The Script Debugging Disabled dialog box might also be displayed. This indicates that script debugging is disabled in Internet Explorer. To enable debugging for client script, follow the directions in the dialog box.

    Click Yes to continue debugging.

  4. Verify that the project runs as expected.

    Do not continue with the conversion process until all build and run-time errors are resolved.

  5. In Solution Explorer, right-click the name of the project and then click Properties.

  6. Click the References tab.

  7. Make a note of the references that are required in the project.

    When you create a new project in the next section, you must make sure that any references in this project also appear in the new project.

Creating a Visual Studio 2008 Web Application Project

You can now create a Visual Studio 2008 Web application project that you will convert to.

To create a Visual Studio 2008 Web application project

  1. In Visual Studio 2008, in the File menu, click New, and then click Project.

    Note

    You create a Web application project as a Visual Studio project, not as a Web site.

    The New Project dialog box is displayed.

  2. Under Project Types, select Web.

  3. Select the programming language that you want to use for the project.

  4. Under Templates, select ASP.NET Web Application.

  5. Enter a name, location, and solution name for the project, and then in the Solution list, select Create New Solution.

    Note

    Create the project in a separate folder from the Visual Studio 2005 Web site that you are converting. This simplifies the conversion process.

  6. In the .NET Framework versions list, select the .NET Framework version that you targeted in the initial conversion.

  7. Click OK.

    The existing Web site is closed, and the new Web application project is created.

  8. Delete the Default.aspx and Web.config files that are created with the new project.

  9. In Solution Explorer, expand References and check the list of default references against the references that were required in the project that you are converting.

  10. If additional references are needed, right-click the References node, click Add Reference, and then in the Add Reference dialog box, create the required references.

Copying Files to the Web Application Project

You can now copy the project files from the old project to the new Web application project.

To copy the file from the old project to the Web application project

  1. In Windows Explorer, browse to the folder that contains the Visual Studio 2005 Web site project files.

  2. Select the files and folders that you want to add to the new project, and copy them.

  3. In the new project in Visual Studio, in Solution Explorer, right-click the project node, and then click Paste to add the copied files to the new project.

Converting ASP.NET Code Files

ASP.NET Web page files and user-control files in Visual Studio 2008 that use the code-behind model have an associated designer file. The files that you just converted will have an associated code-behind file, but no designer file. Therefore, the next step is to generate designer files.

Note

Only ASP.NET Web pages and user controls that have their code in a separate code file require a separate designer file. For pages that have inline code and no associated code file, no designer file will be generated.

To convert ASP.NET code files

  1. In Solution Explorer, right-click the project node, and then click Convert To Web Application.

    The files are converted.

  2. Verify that the converted code files have a code file and a designer file.

Testing the Web Application Project

After you have finished converting files, you can test the project to make sure that it is running correctly as a Web application project.

To build and run the converted project

  1. On the Build menu, click Build to compile the application.

    Any missing references or other compile issues in your project are displayed in the Error List window.

  2. Run the project.

  3. Verify that the converted project runs as expected.

Next Steps

If you want to convert a Visual Studio 2005 Web site project that contains AJAX features to Visual Studio 2008, the overall process is similar but requires additional steps. After converting the Visual Studio project, perform the steps that are described in How To: Upgrade an ASP.NET AJAX 1.0 Web Project to .NET Framework 3.5.

You might want to convert other types of projects from earlier versions of Visual Studio to Visual Studio 2008. For more information, see Overview: Converting Visual Studio Web Sites and Projects to Visual Studio 2008.

See Also

Tasks

How To: Upgrade an ASP.NET AJAX 1.0 Web Project to .NET Framework 3.5

Concepts

Overview: Converting Visual Studio Web Sites and Projects to Visual Studio 2008

.NET Framework Targeting for Web Sites

Migrating and Converting ASP.NET Web Sites