This documentation is archived and is not being maintained.

Web Solution and Project File Conversion

Visual Studio 2005 changes the Web project model in many ways. For example, a project file is no longer needed because all files in the Web application folder are considered part of the Web project.

The new Web project model affects the conversion of files such as ASP.NET Web Forms pages (.aspx files), ASP.NET user controls (.asxc files), the Global.asax file, and the Web.config file. The exact changes made in these files depend on the programming language of the project that is being converted.

Visual Studio 2005 changes the code-behind model to use partial classes, which allow a class to span multiple files. In the previous code-behind model, the .aspx file inherits from a compiled class file created from the corresponding code-behind file (.aspx.vb or .aspx.cs). In the new code-behind model, the .aspx file inherits from a compiled class consisting of its corresponding .aspx.vb or .aspx.cs file, as well as a stub file that is generated from the .aspx file and that defines the field declarations for the controls that are used in the .aspx file. This change allows the auto-generated code to be separated from the user's code. User controls (.ascx) and the code-behind files for user controls are treated similarly. For details about the code-behind model, see ASP.NET Web Page Code Model.

Visual Studio 2005 changes the compilation model from producing one assembly to producing many assemblies. Each ASP.NET Web page and user control can be compiled into its own assembly. This change allows more deployment scenarios, such as publishing your source code to the server and letting it dynamically compile parts of your Web application, as needed.

The following changes are made to ASP.NET Web pages and user controls during the conversion to the new ASP.NET version 2.0 code-behind model:

  • The CodeBehind attribute in the @ Page directive is changed to a CodeFile attribute.

  • An Inherits attribute is added to the @ Page directive pointing to the associated compile-with class file.

  • All code-behind class definitions are changed to implement the Partial keyword.

  • Member declarations for user controls are removed from the code-behind page. In the compile-with model, instances of the user controls are created automatically from the declarative code.

  • Events are bound to controls using declarative syntax. For example, the Click event for a Button control is bound to the control by adding an OnClick attribute to the asp:button element in the declarative code. Delegates and the Visual Basic Handles keyword in methods are removed. Delegates are not removed for members that are not represented in the declarative code, such as delegates for dynamically created controls.

  • Member declarations in class files (but not in page classes) that are marked as Friend or Internal are changed to Public.

  • Debugger breakpoints are not converted, and they will not appear in the converted files.


    If a Web page or user control does not have a CodeBehind attribute in the @ Page directive, it is not converted. Similarly, Web pages or controls that contain a Src attribute are left intact.

The following changes are made to stand-alone code files:

  • The stand-alone code files are moved to the App_Code directory.

  • Member declarations that are marked as Friend or Internal are changed to Public. This change is required because with multiple assemblies the access level must be such that the members are visible from assemblies other than the assembly containing the compiled stand-alone code file.

  • Calls to the Type..::.GetType method are changed to use the BuildManager..::.GetType method. The BuildManager..::.GetType method finds types within top-level assemblies.

  • Debugger breakpoints are not converted, and they will not appear in the converted files.

Settings in a page that pertain to the designer are handled in different ways during conversion:

  • The MS_POSITIONING attribute (flow layout or grid layout) is left in place, and Visual Studio retains this setting along with the absolute positioning attributes of individual controls. However, by default, new pages in Visual Studio use flow layout and do not include the MS_POSITIONING attribute.

  • The <meta> tag for the default client script language is left intact.

When the Global.asax file is converted, its code-behind file is moved to the App_Code directory. The conversion process makes the following changes:

  • The CodeBehind and Inherits attributes are removed from the @ Application - Global.asax directive.

  • A Language attribute is added to the @ Page directive, if one is not already specified.

  • For Visual Basic, a Namespace statement is added to the class file. The namespace is defined by the root namespace in the Web project.

In Visual Studio 2005, the Web.config file supports a wider variety of elements than it does in Visual Studio .NET. For example, project settings that still apply to Visual Studio are often converted to the Web.config file. For details, see Web Project Settings Conversion.