This post originated from an RSS feed registered with .NET Buzz
by Peter van Ooijen.
Original Post: ASP.NET 1.1 working with an ASP.NET 2.0 web.config file
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
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
<?xmlversion="1.0"encoding="utf-8"?>
<configuration>
<configSections>
<!-- tell .NET Framework to ignore 2.0 sections -->
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.