Integrating ASP.NET with Drupal in the Acquia Stack

A while back, I posted this about running SharpMap on Apache. At the time, the ability to run ASP.NET on Apache was mainly a curiosity to me but had little practical value. Recently, I had the need to revisit this technique for a project. I used the same post I had used previously as a reference, although the comment by Carlos there was more up-to-date and served me well this time.

This time, we were migrating an old custom-built site to the Drupal CMS. The old site was a mixture of ASP Classic and ASP.NET. Drupal is a PHP-based CMS. Due to the deadline for completing the migration, there were two ASP.NET applications that we planned to leave in place. They automated custom workflows and our schedule didn’t allow for rewriting them. Drupal had been installed as part of the Acquia stack installer that includes Apache, PHP, Drupal and MySQL.

Following the instructions I had used previously, I integrated mod_aspdotnet in the Apache http.conf. I made the following entries, as instructed (these are sample entries for purposes of this post).

AspNetMount /SampleASP "c:/SampleASP"
Alias /SampleASP "c:/SampleASP"

These entries mount the ASP.NET application where it sits physically and alias it to a virtual directory in Apache. Having done this before, I was not worried. This time, however, it did not work. After some research, I realized that these directives were in conflict with some mod_rewrite entries that are part of the stack installer. They are:


ServerName localhost
RewriteEngine On
RewriteOptions Inherit
RewriteCond %{REQUEST_URI} !/acquia-drupal.*
RewriteCond %{REQUEST_URI} !/phpmyadmin.*
RewriteRule ^(/.*)?$ /acquia-drupal$1

In this case, any URI that does not look like http://${hostname}/acquia-drupal is rewritten to match that format. So my URI of http://${hostname}/SampleASP was being rewritten as http://${hostname}/acquia-drupal/SampleASP which does not exist and promptly fails. The solution to this problem was to modify the AspNetMount and Alias entries above to this:

AspNetMount /acquia-drupal/SampleASP "c:/SampleASP"
Alias /acquia-drupal/SampleASP "c:/SampleASP"

This redirected properly and the ASP.NET executed. So, the lesson here is that, if you choose to use a stack installer, make sure you understand the customizations that the installer makes to the products it includes.