Virtual Developer Workshop: Containerized Development with Docker

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.



  • Peculiarities

    Posted by jekora on 12/21/2005 03:03pm

    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 03:38pm

      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.

  • very useful

    Posted by minoo_agarwal on 12/20/2005 06:09pm

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

  • This article was very useful to me

    Posted by Reetu on 12/02/2005 12:57am

    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 04:02pm

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

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date