Thursday, February 15, 2007

Configuring ASP.Net 1.1 on IIS 6.0 in x64 versions of windows Server

32 vs 64 bit versions of windows server
The 32Bit version of windows 2003 does not take full advantage of 64 bit hardware. We got a double Xeon machine with windows 2003 server R2 x64 which is the 64 bit version of the OS. The advantages of the OS is the increased memory allowance (32 bit only allows 4GB form which .Net can only use 2GB, with the 64bit you can go up to 32GB of memory which makes a lot of sense for a web server.
The problem
By default iis 6.0 is running as a 64 bit host which means it will not run 32 bit applications.
ASP.Net 1.1 was never ported as a 64 bit app (2.0 was).
There is a way to configure iis to run 32 apps like ASP.Net 1.1:
A couple of things to know - if you allow iis to run 32 bit processes this will affect all applications. In the ASP.Net tab in IIS MMC console will disappear - making it impossible to switch between versions 1.1 and 2.0 for a specific website - this can be done only from the command prompt.
The solution
Since I have a busy web server to manage with many sites I automated the process by writing a batch file that takes 2 arguments; the .Net framework version and the target site id. The scripts Changes the registration for that site.
To make this work - open notepad and paste the following:

@echo off

IF(%1) == () GOTO :MissingArgs

IF(%2) == () GOTO :MissingArgs

IF (%1) == (1.1) GOTO :VER11

IF (%1) == (2.0) GOTO :VER20



ECHO 1.1

@echo on

c:\windows\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis -s /w3svc/%2/root

@echo off



ECHO 2.0

@echo on

c:\windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -s /w3svc/%2/root

@echo off



ECHO Usage change_asp_ver version sitenumber




Save the file as change_asp_ver.bat in a directory you can recall like c:\scripts\
To run the script you will need to find out the site id that you wish to change. Open the IIS MMC console click websites and you will see the site identifier on the right.

If you want to change site id 1234 to version 1.1 and you saved the file in the scripts directory you will type:
Start->run->cmd (enter)
cd c:\scripts\ (enter)
change_asp_ver 1.1 1234 (enter)

You might need to change some of the paths in your script if you used non standard directories to install the frameworks.

This is based on a post response to microsoft.public.interserver.iis