Hi everyone!
This time, I’m here to warn you of a bug in ASP .NET 1.1.
The scenario
Let’s say that you have a web application. Let’s called HttpModuleIssue. That web application has a child web application that I’ve called HttpModuleIssueSubApp.
Let’s look how this is configured in IIS.

Each one of this web applications has a Web.Config file.
Quick Web.Config talk
A web.config file is, has you know, a special file where you can manage the configuration of your application.
The root of the ASP.NET configuration hierarchy is a file referred to as the root Web.config file, and it is located in the same directory as the Machine.config file. The root Web.config file inherits all of the settings in the Machine.config file. The root Web.config file includes settings that apply to all of the ASP.NET applications that run a specific version of the .NET Framework. Because each ASP.NET application inherits default configuration settings from the root Web.config file, you need to create Web.config files only for settings that override the default settings. More info here.
Adding a HttpModule
Let’s add a HttpModule to our main web application HttpModuleIssue.
The HttpModule doesn’t do anything usefull… it’s only to show you the dreaded bug. Anyway, here it is:
using System;
using System.Web;
namespace HttpModuleExProject
{
///
/// Summary description for HttpModuleEx.
///
public class HttpModuleEx: IHttpModule
{
public void Init(HttpApplication app)
{
// Register for pipeline events
}
public void Dispose()
{
// Nothing to do here
}
}
}
Now, not only do we have to put the assembly of our HttpModule inside the bin directory of HttpModuleIssue, but we must also add an entry to the HttpModuleIssue’s web.config file registering the HttpModule.
<system.web>
<httpModules>
<add name="HttpModuleEx"
type="HttpModuleExProject.HttpModuleEx, HttpModuleEx" />
</httpModules>
The name attribute can be any name that we like. The type attribute must be in the format “namespace.typeName, typename”.
This works with no problems. But if you visite a page inside the web application HttpModuleIssueSubApp, you will see this runtime error:
Well, after our previous web.config talk, that should be expected. After all, HttpModuleIssueSubApp doens’t want to use that HttpModule, but it’s web.config file inherits the registration of the HttpModule.
The solution that should work
According to the documentation you can remove the HttpModule that some parent web application might have registered. It should be as simple as putting the following code inHttpModuleIssueSubApp’s web.config file:
<system.web>
<httpModules>
<remove name="HttpModuleEx" />
</httpModules>
The sad true
Unfortunately, it doens’t work at all. The runtime error still happens. I’ve seen a couple of developers complaning about this issue… This issue was found using ASP.NET 1.1.
The sad solution
The only solution is copying the HttpModule assembly to the child web applications…
You can download the source code used for this article here.
Any comments about this bug/issue are appreciated.
See you next time!