In a recent post I described the trouble an asp.net 1.1 application has with a web.config file targeted at asp.net 2.0. The main problem is that the asp.net 1.1. runtime does not understand parts of the 2.0 web.config and crashes. My first solution was to move settings to the global 2.0 config. In a brilliant comment Joshua Flanagan suggested to bring the problem to its owner. His idea was to teach asp.net 1.1 the 2.0 specific sections and tell it to ignore them. This sounds more complicated than it is and works well.
For a good overview of the web.config in 1.x I again recommend James Avery little book, I blogged before on that. The global configuration of asp.net 1.x is in the machine.config file in \WINDOWS\Microsoft.NET\Framework\v1.x\CONFIG. (Note that 1.x does not have a global web.config like 2.0). This file has a list of sections and the assemblies to handle the sections. The framework has a very handy handler, the IgnoreSectionHandler. Which does exactly what's desired: nothing. This snippet tells asp.net to ignore the connectionstrings section
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- tell .NET Framework to ignore 2.0 sections -->
<section
name="connectionStrings"
type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowLocation="false" />
<!-- tell .NET Framework to ignore CLR sections -->
<section
name="runtime"
type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowLocation="false" />
<section
name="mscorlib"
Entering it is easy, copy the runtime section, just below and change the name attribute. Asp.net has far more sections than 1.1, like the system.web.rolemanager and system.web.membership, which came by in the previous post. Add the sections as needed. Perhaps it would have been nice if there was an installation tool which modifies the 1.x machine.config for all 2.0 specific sections. Hey MS, are you listening?
There is one incompatibility which is not handled. In 2.0 the configuration node has a namespace attribute.
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
1.x trips over that. Delete the attribute:
<configuration>
<appSettings/>
<connectionStrings>
Asp.net 2.0 works without it. Assigning a namespace might be useful for future versioning, but it hinders backward compatibility.
Read: ASP.NET 1.1 working with an ASP.NET 2.0 web.config file