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

Tuesday Nov 29th 2005 by Manoj Agarwal
Share:

Find out which versions of the .NET Framework and Visual Studio are installed, or configure an ASP.NET 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.

Share:
Home
Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved