Configure a Web Application to Use a Specific Version of ASP.NET

Have you faced the problem of having different versions of ASP.NET installed on your machine and wanting to run a particular ASP.NET application in a specific version and not been able to do that, even after trying various things like tinkering with the web.config file or checking different attributes of the aspx file's Page directive?

I faced this problem when I installed Visual Studio 2005 on my machine that already had Visual Studio 2003 on it. Due to this, I had ASP.NET 2.0 and 1.1 installed side-by-side on my machine. I wanted to try out some of the samples given in the 2.0 documentation and so created a virtual directory on IIS and put the a sample 2.0 aspx file in it but when I viewed this aspx file from a browser then a runtime error was being thrown as the file was being treated as a ASP.NET 1.1 file. I had to find a way to make this file run under ASP.NET 2.0.

Different Versions of ASP.NET Released

To date, Microsoft has released three main versions of ASP.NET: 1.0, 1.1, and 2.0.

Note: The ASP.NET version is the same as the .NET Framework version it is part of.

If you already have a version of the .NET Framework and ASP.NET installed and then want to install a later version on the same machine, there are two ways to do this:

  1. Install the newer version in a side-by-side mode. By doing this on a single machine, one could have multiple versions of the framework installed and, for a Web application, one could choose the ASP.NET version to run it under.
  2. The newer version install removes the older version and replaces it with the newer version.

By default, when version 1.1 was installed, it removed 1.0. When version 2.0 is installed on a machine that already has version 1.0 or 1.1 then, by default, it gets installed in the side-by-side mode, which means that one would have two versions of ASP.NET running side-by-side.

Finding the Different Versions of ASP.NET Installed

The .NET Framework SDK provides the IIS Registration tool (Aspnet_regiis.exe). This tool is installed in the %SystemRoot%\Microsoft.NET\Framework\versionNumber folder. This tool can be used to find the installed versions of ASP.NET using the command

aspnet_regiis.exe -lv

A sample output can be seen in Figure 1.

Figure 1: Getting a list of installed versions of ASP.NET on the machine

Configuring an ASP.NET Application to Use a Specific Version of ASP.NET

If you have different versions of ASP.NET installed side-by-side, you can specify which version to use either at the Web site level or at a virtual directory\ASP.NET application level. This can be done with the IIS Management Console by using these steps:

  1. Open the IIS management console and navigate to the Web site or ASP.NET application folder depending on which level you wish to make the change.
  2. Right-click the folder and click Properties. The Properties dialog box appears.
  3. Go to the "ASP.NET" tab and select the version to use in the "ASP.NET version" drop-down list. A sample is shown in Figure 2.

Figure 2: The ASP.NET tab in the ASP.NET application's Properties dialog box

If you want to configure the ASP.NET application from the command prompt, check this article from Microsoft Support.

Determining the ASP.NET Version Your Application is Running Under

If you are not sure about which ASP.NET version your Web application is running under, the easiest way to determine this is to put some syntax error in your code due to which, at runtime, an error is thrown by ASP.NET in which it mentions the version!

The other way is to get the common language runtime version by using the System.Environment class. A sample aspx page, in both C# and Visual Basic.NET versions, has been provided with this article; it can be put in the ASP.NET application folder whose version is to be found and then accessed from a browser. Please see the attached sample.



About the Author

Manoj Agarwal

Manoj Agarwal has over a decade of industry experience on a wide spectrum of technologies. He currently runs a software company called Falconsoft Systems which specializes in consulting, application development and training mainly in Microsoft .NET. Manoj was among the top-10 winners at the nationwide Microsoft Technology Adopter Challenge.

Downloads

Comments

  • Peculiarities

    Posted by jekora on 12/21/2005 07:03am

    The asp.net version on iis.mmc and the example script (using the System.Environment class) should indicate same framework version for particular site/vdir, right? On my server, the runtime version of particular site should be 1.1 and has been reconfigured to that several times -> changes to newest installed 2.x version "by itself", which is not indicated by iis.mmc but indicated by using the System.Environment class??!! I'm wondering if COM interop calls of 2.0 application could cause the change of framework version for this 1.1 app as well (actually it's legacy asp using COM components implemented with 1.1 via COM interop)...? Still doesn't explain why the iis.mmc and script output are not in sync. Any cure?

    • Re: Peculiarities

      Posted by falconsoft on 12/21/2005 07:38am

      The behaviour you are getting is indeed strange. Can you check the following-
      
      1. Find out the versions of ASP.NET installed on the machine (for this open a Visual Studio.NET cmd prompt and run the command "aspnet_regiis -lv"). This will tell us if 1.1 is installed.
      
      2. Create a new virtual directory through the IIS manager mmc and set the ASP.NET version to 1.1 and see if this works or it gets set to 2.x.
      
      Pl let me know.

      Reply
    Reply
  • very useful

    Posted by minoo_agarwal on 12/20/2005 10:09am

    articule is informative and easy to follow. Helped me great deal.

    Reply
  • This article was very useful to me

    Posted by Reetu on 12/01/2005 04:57pm

    I was facing some issues with versioning. I went through this article, applied the settings mentioned and it worked fine for me. Thanks a lot.

    • Good Job

      Posted by isulaimani on 12/07/2005 08:02am

      This is the common problem faced and by providing a solution in such a simple language, the author has done a good job.

      Reply
    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 20, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds