Multi-targeting of web projects using Visual Studio 2010 Beta1

The multi-targeting feature of Visual Studio 2010 allows web developers to develop web applications targeting ASP.NET 2.0, 3.0, 3.5 and 4.0. The key benefit of multi-targeting is that you can use Visual Studio 2010 to create and develop new projects that target earlier versions of the .NET Framework (such as 2.0, 3.0 and 3.5). Multi-targeting in VS 2010 also lets you continue to develop projects that were created using earlier versions of Visual Studio such as Visual Studio 2005 and Visual Studio 2008.

What’s different about Multi-targeting in Visual Studio 2010?

We supported multi-targeting of web applications in Visual Studio 2008 as well. But the capabilities we had for multi-targeting in VS 2008 were really a pseudo form of multi-targeting, i.e. even though VS 2008 allowed us to target different versions of the ASP.NET framework 2.0, 3.0 and 3.5, the underlying Common Language Runtime (CLR) for all these frameworks is the same (= the .NET CLR 2.0). With the release of the new ASP.NET 4.0 Beta1 framework (that runs on top of the .NET CLR 4.0 that installs side-by-side with earlier versions of the .NET CLR) along with Visual Studio 2010 Beta1, we now have the ability in Visual Studio to target ASP.NET framework versions spanning multiple versions of the CLR (CLR 2.0 and CLR 4.0).

VS 2010 can detect when your web project is targeting ASP.NET 2.0, 3.0 or 3.5 (that runs on top of CLR 2.0) versus targeting ASP.NET 4.0 (that runs on top of CLR 4.0).


  • VS 2010 allows you to choose ASP.NET 2.0, 3.0, 3.5 or 4.0 as the target framework when you create a new Website or Web Application Project (WAP)

Figure 1


  • You can convert and migrate your web applications built using earlier versions of Visual Studio to Visual Studio 2010. Like you could do with VS 2008, you can continue to have your web project target lower framework versions like ASP.NET 2.0 after conversion. See "Converting web projects from earlier versions of Visual Studio" section below for details.
  • Visual Studio automatically filters controls in toolbox, and types in intellisense and properties window based on the ASP.NET framework version being targeted
  • Compilation and building of the web project works correctly based on the target framework, ie. VS 2010 will show errors when you try to use 4.0 controls or properties in a web project targeting 2.0 or 3.5.
  • You can change targets from one ASP.NET framework to the other via the property pages (as you could in VS 2008). Note: In VS 2010, we prompt you to reload the project when you change the target framework of a website project (VS 2008 used to do this for WAP projects). This is to ensure that the references are updated correctly when you change the target.

New capabilities in VS 2010:

We already had the above multi-targeting capabilities in VS 2008. VS 2010 extends these capabilities to handle ASP.NET 4.0 (and the new CLR 4.0). Additionally, in VS 2010,

  • When using IIS as the web server, VS will automatically update the application pool for the web project in an IIS server on localhost
  • When using the built-in web server, there are now two versions of the built-in ASP.NET Development server in VS 2010, one for each CLR version. VS 2010 will correctly choose the web server version to run based on the framework that the web project is targeting. (You can see which version is in use by right-clicking on the icon for ASP.NET Development Server in your System Tray and choosing ‘Show Details’ – as shown in Figure 2 and Figure 3 below).

Figure 2 – ASP.NET Development Server icon in System Tray


Figure 3


IIS 7 and application pools

When using web projects with IIS 7, you can only specify one CLR version per application pool in IIS. Therefore, a web project targeting ASP.NET 4.0 (and CLR 4.0) cannot be in the same application pool as a web project targeting ASP.NET 3.5 or lower (CLR 2.0) in IIS 7.

When creating new or re-targeting existing localhost IIS WAPs and IIS websites (HTTP websites) using VS 2010 (example, as in Figure 4), it will automatically set the application pool in IIS for you based on the .NET framework that the web project is targeting. (Remember that you need to run VS as admin if you are using IIS as your development server rather than the built-in ASP.NET Development Server). If an application pool for the current runtime version does not already exist in IIS, VS 2010 will create one for you and then assign the web project to this newly created application pool. You can verify this by selecting the application in IIS and viewing the Basic Settings (as shown in Figure 5). VS 2010 does not automatically update the application pool on a remote server, however.

Figure 4


Figure 5



Converting web projects from earlier versions of Visual Studio to Visual Studio 2010

Conversion of projects creating using VS 2005 and VS 2008 to VS 2010

VS 2010 supports conversion of a web project created using VS 2005 or VS 2008 to the latest version of Visual Studio so that you can take advantage of the new features that are available. The feature works similar to the conversion behavior in VS 2008 – you will be presented with the Visual Studio Conversion Wizard that will walk you through the steps to convert your project to VS 2010 (see figure 6). Like in VS 2008, during conversion of your project, a prompt will appear (see figure 7) allowing you to continue targeting the lower .NET framework version such as ASP.NET 2.0, 3.0 or 3.5, or optionally, upgrade the project to target the latest .NET framework version ASP.NET 4.0.

Figure 6


Figure 7


Conversion of projects creating using VS 2003

VS 2010 also supports limited conversion of a web project created using VS 2003. As above, you will get the conversion wizard but there will not be a prompt allowing you to remain in the lower ASP.NET 1.1 framework. This is because VS 2010 only supports targeting of frameworks 2.0 and above. Rather, the ASP.NET 1.1 web project will get upgraded to a ASP.NET 4.0 Web Application Project.

Note: It is always a good practice to take a backup of your web project before converting it to a newer version of Visual Studio.


Bala Chirtsabesan | SDET | Visual Studio Web Developer