Here's how to configure an asp.net 2.0 web application as a SUB APPLICATION of an existing asp.net 1.1 application.
By design the root website, “inherit down” the config file to all sub applications.
When the sub application loads, the runtime loads the config file from the root application and inherits down to all sub applications. This can be useful, sub apps can now inherit from the configuration of the root application, But this usefulness sometimes can cause us a problem when the web.config file adds
When you access the 2.0 sub site, the runtime tries to load the modules, assemblies and headers referenced in the root web.config, by looking in the 2.0 bin directory. The runtime will not find these in the bin directory and throw an exception.
Now there's a couple ways to resolve this.
1. Copy the dlls to the sub applications bin folder
2. configure the sub application to remove the referenced dlls.
Firstly, I've only tested this against IIS 6.
Assuming your 1.1 web app is configured and working and you've created and configured your 2.0 app as a sub application within IIS 6.0. The first thing to ensure is that your 2.0 app uses its own app pool. The credentials can match your 1.1 app, but its important to have its own app pool.
Now lets assume your root (1.1) application has the following section in the web.config file
<add name="Module1" type="MySuperApp.Modules, MySuperApp.Modules.Module1" />
<compilation batch="true" debug="true" defaultlanguage="vb" batchtimeout="30" />
<add assembly="MySuperApp.Specialized.Utilis" />
<add assembly="MySuperApp.SomeOtherStuff" />
<add type="MySuperApp.Handlers.BobHandler, MySuperApp.Bob" validate="false" path=".bob" verb="GET" />
The above references tell the runtime to load up the required dlls.
As we know, the web.config is “inherited down” to the sub applications.
So within the sub applications config file, we remove the references.
The 2.0 apps web.config file should contain the following…
<remove assembly="MySuperApp.Specialized.Utilis" />
<remove assembly="MySuperApp.SomeOtherStuff" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
<remove verb="GET" path=".bob" />
These are all within the system.web node.
Take special note of the httpModules section. I’ve issued a Clear and not a explicit
remove. This is done so that the sub application can be scaled to
a full root (standalone) website without the need to amend the config file.
Points of Interest
This seems to work for my particular situation, however there's others that claim it does not work and as a last resort have to include the dlls in the bin folder. If there's any other solutions out there, I'd appreciate it if you could share.
Created: 05 October 2008 :
Hope this helps!