Udostępnij za pośrednictwem


Web Project Conversion from Visual Studio .NET

Microsoft Visual Studio 2005 manages Web site projects and files differently than Visual Studio .NET 2002 and Visual Studio .NET 2003 (which are collectively referred to as Visual Studio .NET in the rest of this topic). As a result, when you want to use Visual Studio 2005 to work with a project that was created in Visual Studio .NET, the project will be converted to a Web application project. The process occurs automatically when you open a Visual Studio .NET project in Visual Studio 2005; the conversion wizard will convert your Web application and minimize the amount of manual editing that is needed to finish the conversion. This topic describes the conversion process, and specifies the changes that are made in Visual Studio .NET files. For more information about Web Application Projects, see Web Application Projects Overview.

The overall goal of the conversion process is to enable you to open a Visual Studio .NET project in Visual Studio 2005, convert it automatically, and then run it with no change in functionality. The conversion process is one-way — after you have converted a project to Visual Studio 2005, you will not be able to work with it in Visual Studio .NET. Although Visual Studio 2005 makes changes to the files in a project, you can make backup copies of the original files. You will still be able to open Visual Studio 2005 files in Visual Studio .NET as standalone files (without certain features, such as IntelliSense), but the overall project will have been altered. If necessary, you can restore the Visual Studio project from the backup files.

Security noteSecurity Note:

Before you convert an existing project to Visual Studio 2005, examine all the existing files, especially if you are not the only person who has modified the project. Look for unfamiliar files. This helps protect against importing malicious code into Visual Studio. In general, it is recommended that you run Visual Studio 2005 as a typical user and not as an administrator unless you need to perform administrative tasks.

This topic includes information about the following aspects of converting Web projects to Visual Studio 2005:

  • Visual Studio 2005 Conversion Process

  • Solutions and Projects

  • Conversion of Project Settings

  • Converting Specific Configurations

  • Data Components

  • Code Modules

  • Web Services

  • Conversion and Source Code Control

Visual Studio 2005 Conversion Process

The following list outlines the basic Web project conversion process from Visual Studio .NET to Visual Studio 2005:

  1. In Visual Studio 2005, open an existing Visual Studio .NET Web site. You can open any of the following files and directories:

    • A solution (.sln) file

    • A project (.vbproj, .csproj, or .vjp) file

    • The root directory of the Web site

  2. If a project file is found, then Visual Studio 2005 will invoke the conversion wizard to convert the Web project.

    Note

    Web projects no longer need a project file in Visual Studio 2005; all the files that are located in the Web project folder are considered part of the Web project.

    For details on the steps in the conversion wizard, see How to: Convert a Visual Studio .NET Project to Visual Studio 2005.

  3. Visual Studio 2005 converts your Web application from using ASP.NET version 1.x to using ASP.NET version 2.0. For example, the CodeBehind attribute in ASP.NET Web pages and user controls is changed to the new CodeFile attribute. If a file is modified, the original file permissions are not preserved — the new file will have read/write permissions, which are given to users. For details about changes that were made to files, see Web Solution and Project File Conversion.

  4. Standalone class files are moved to the App_Code directory.

  5. Other types of files are not touched. This includes graphics, HTML files, and so on. Additionally, the migration process ignores files that are outside the application. This helps prevent malicious users from accessing files that are outside the application by using relative paths in a project file.

  6. A report named ConversionReport.txt is created and stored in the root directory of the converted Web project. This report file lists all the changes that were made to your Web project, and it might contain informational comments, warnings, and errors that were found during conversion. If you select the option in the conversion wizard to show the conversion log after the wizard is complete, you will see a conversion report in Visual Studio 2005. For more information about the format of this report, see Migration Conversion Report Format.

Note

If your project uses source control, the Web project files will not be under source control after they are converted to Visual Studio 2005.

Solutions and Projects

If you open a solution file in Visual Studio 2005, Visual Studio inspects the contents of the .sln file to determine what types of projects it contains. Visual Web Developer will convert only Web applications (Web pages and Web services). If you open a solution file that contains other types of projects, such as Windows Forms projects or console applications, only the Web projects will be opened and converted.

If you open a project file, Visual Studio 2005 converts the files referenced by that project. No attempt is made to convert files that are in the same directory as the project files that are not part of the project. This can lead to build errors. For example, if you have a file called Page1.aspx and a code-behind file called Page1.aspx.cs that is in the folder but is not included in the project file, then the conversion wizard will not convert either file. When you compile, you will get build errors because both the Page1.aspx and Page1.aspx.cs files will be considered part of the converted Web application.

If the project contains directories that have reserved names in Visual Studio 2005, such as App_Data or App_GlobalResources, Visual Studio 2005 appends "_old" to the existing directory names (for example, App_Data_old). To resolve any broken references that this might cause, you must manually change your code to refer to the new directory or move the code into the reserved directories, such as App_Data or App_GlobalResources. For more information, see Shared Code Folders in ASP.NET Web Sites.

Conversion of Project Settings

Because Visual Studio 2005 does not maintain settings in project files, settings for Visual Studio .NET projects are either converted to the Web.config file, or they are not converted if the settings do not apply in Visual Studio 2005 as they did in Visual Studio .NET.

For details, see Web Project Settings Conversion.

Converting Specific Configurations

If the source project contains a custom build configuration, the conversion process prompts you to select which configuration that you want to convert. Your choice determines what project settings are used during conversion to configure the Web site in its new format.

If the source project contains only the default build configurations (Release and Debug), the conversion process uses the settings in the Debug configuration.

Data Components

The model for adding data access to Web pages has changed in Visual Studio 2005. Although Visual Studio 2005 still uses ADO.NET components for data access, Visual Studio 2005 pages control data access by using data source controls, which encapsulate data connection objects, data command objects, and datasets or data readers. For details, see Data Source Controls Overview and Data-Binding Expressions Overview.

The Visual Studio .NET model of working with explicit instances of data connections, data commands, and datasets is still supported in Visual Studio 2005. When Visual Studio 2005 converts pages or files that involve data access, the existing data objects are converted intact, and they continue to work in Visual Studio 2005 as they did in Visual Studio .NET. However, you will not be able to work with these data components in the Visual Studio 2005 Web page designer (Design view) because the designer does not support these objects. You can still work with them in Source view.

Datasets

During conversion, Visual Studio 2005 converts the schema (an .xsd file) of a typed dataset and stores it in the App_Code directory. The .vb or .cs file that represents the dataset class (as generated by Visual Studio) is not converted because the Web site can reference the .xsd file automatically.

Code Modules

Stand-alone code modules (.vb and cs files) are moved as-is to the App_Code directory. (This does not apply to .vb and .cs files that are associated with Web pages or other ASP.NET files.) Any member declarations that are marked as Friend or Internal are changed to Public.

For .vb files, the conversion process adds a Namespace statement pointing to the root directory of the Web project. In addition, the conversion process adds any classes that have not already been imported automatically by ASP.NET to the compilerOptions attribute of the compiler element.

Web Services

Web services are converted into essentially the same format that they have in Visual Studio .NET. The class file for a Web service (the .asmx.vb or .asmx.cs file) is moved to the App_Code directory. Any members that are marked as Friend or Internal are changed to Public. The CodeBehind attribute of the @ Page directive in the .asmx file is updated to point to the new location of the code.

In Visual Basic Web services, a Namespace statement is added to the class file that is defined by the root namespace in the Web project. The conversion process also adds an Imports statement to the Visual Basic file to define all imports for the Web service that are not already imported by default by ASP.NET.

Conversion and Source Code Control

Source code enlistments are not converted. After conversion, the files in a Web site are no longer under source control.

See Also

Tasks

How to: Convert a Visual Studio .NET Project to Visual Studio 2005

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

Concepts

Web Solution and Project File Conversion

Web Project Settings Conversion

Migration Conversion Report Format

Web Application Projects Overview

Web Application Projects Overview