While running your ASP.net application you might have found it to be running on Integrated Web development environment. Visual Studio 2010 comes with two version of Integrated Web Development environment which could run side by side. In case you run your ASP.NET application in VS 2010 you can have an option to choose between the two version of Web Development environment, one running CLR 2.0, which was there before VS2010 and a new version of Web Dev with CLR 4.0. Multi – targeting allows you to configure your visual studio to run more than one Web Dev server at a time one using CLR 2.0 and another using CLR 4.0

In one of my ASP.NET Online session I had talked about the multi targeting features of Visual Studio 2010 for web development. During the demo I have shown, how we can target two different version of .NET CLR version same time. Some of the attendees having some doubts on that, So in this blog post, I am going to explain how we can target two different version of CLR at same time.

To demonstrate it, Start with a new Visual Studio Instance, and Create a solution file which contains two different Framework version of web applications.  Let’s say there are two web application which are targeting to ASP.NET 3.5 and ASP.NET 4.0 version.

1 2

Below is the structure of your solution files, which contains two different project of different Framework version.

3

Now, If you run these two application individually,  for .NET 3.5 (ASP3_5Apps ), you will see it is targeting to CLR Version 2.0 .

target35

And if you set 4.0 project as startup project, you will see the ASP.NET 4.0 Application is targeting to CLR Version 4.0

target40

Now, we can see that individually two different application targeting to two different framework. Now lets have a look, if we run these two different framework application same time. To set multiple project as start up project, Right Click on Solution and Go To Properties and select the option for multiple startup project. You can read my How to setup multiple startup projects in Visual Studio ?  blog post more details.

multiplestartup

Click on Apply and Ok. And Run the application.  you will find that both application runs at same time and both of them targeting to two different framework version.

two

Yes they are targeting to two different framework same time. This is really helpful, for backward compatibility, like say, your services running on .NET 2.0 version and you are developing frontend application using .NET 4.0.

   If you are hosting the Visual studio application in IIS,  VS 2010 will correctly update the Application pool asp.net version based on the selected framework from Visual studio.

targetiis targetiisff

Summary : In this blog post I have explained how you can use  different version of Integrated ASP.NET engine to run ASP.NET Application in VS 2010 along with targeting CLR version (CLR 2 and CLR 4) same time. I have also explained Side by Side Execution of different framework version of ASP.NET application

Shout it

Hope this will help you.

Thanks !

Abhijit