The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ASP.NET 1.1 working with an ASP.NET 2.0 web.config file

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter van Ooijen

Posts: 284
Nickname: petergekko
Registered: Sep, 2003

Peter van Ooijen is a .NET devloper/architect for Gekko Software
ASP.NET 1.1 working with an ASP.NET 2.0 web.config file Posted: Jun 23, 2006 2:50 AM
Reply to this message Reply

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.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter van Ooijen
Latest Posts From Peter's Gekko

Advertisement

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

Topic: Feeding Frenzy Episode 3 Previous Topic   Next Topic Topic: Befuddled Tech - Sybase strings and nulls

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use